From patchwork Mon Apr 2 01:24:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 894091 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-475692-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="X8362+28"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40DvfT3W5rz9s0q for ; Mon, 2 Apr 2018 11:25:02 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:date:mime-version:content-type :content-transfer-encoding:message-id; q=dns; s=default; b=e/CZU cZYqMF3Lzt9oz0cl3l3s8G8sejq7m4OOCCm5ZFtFlOAJKiTu38EnpExjQEjIm57J npaLjg5Vhy3En5QxgpRSDkY7rNDF4vwTzQogkx+RXRKB1cLEgMqaNO/6QDmQbED2 DbnRKcOT+EmPS3W43JXjnMjABuq+v3iQ0zI+PY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:date:mime-version:content-type :content-transfer-encoding:message-id; s=default; bh=3Tztm8iCZij chYn2iVH8VUENq2c=; b=X8362+287YZn31i2qQ74EqlkjyLQ54+0fEjL4m97WUI 1DqqElkPnLrHBiPIzzP8bFo21NlNNyd2B5RB43pthjVjHXTfxPQ3L4D18qUuAB7n bFrbRB/dYAakQBHwzMQc1Mp4I66zunUvuMLRu48ag9Yq0osNTXXYjelKl6qds6lw = Received: (qmail 66539 invoked by alias); 2 Apr 2018 01:24:54 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 66480 invoked by uid 89); 2 Apr 2018 01:24:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=intend, 258958, __vector, safely X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Apr 2018 01:24:40 +0000 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w321ODer088196 for ; Sun, 1 Apr 2018 21:24:37 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0a-001b2d01.pphosted.com with ESMTP id 2h33x91dxq-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Sun, 01 Apr 2018 21:24:37 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 1 Apr 2018 19:24:36 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 1 Apr 2018 19:24:34 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w321OX7C5964202; Sun, 1 Apr 2018 18:24:33 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8500178041; Sun, 1 Apr 2018 19:24:33 -0600 (MDT) Received: from bigmac.rchland.ibm.com (unknown [9.10.86.142]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id 5A0C178037; Sun, 1 Apr 2018 19:24:33 -0600 (MDT) To: GCC Patches , Segher Boessenkool From: Bill Schmidt Subject: [PATCH, rs6000] Undefine vector, bool, pixel in xmmintrin.h Date: Sun, 1 Apr 2018 20:24:32 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18040201-0012-0000-0000-000015FB7C72 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008786; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000255; SDB=6.01011797; UDB=6.00515613; IPR=6.00791069; MB=3.00020365; MTD=3.00000008; XFM=3.00000015; UTC=2018-04-02 01:24:34 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18040201-0013-0000-0000-0000521CB4ED Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-04-01_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804020014 Hi, The xmmintrin.h and related header files make use of altivec.h to enable vector intrinsics to be used for compatibility. However, for C++ or C11 using strict ANSI compliance, this causes a collision with the "bool" keyword. We intend to later change altivec.h to not define these keywords under those conditions, but this could cause a certain amount of community churn, so we want to try a distro build with this before making such a change in GCC 9. Since these compatibility headers are new in GCC 8, we can safely undefine these following the include of altivec.h without disturbing existing code. Note that for strict-ANSI C11 code, stdbool.h must be included after including xmmintrin.h in order to enable the bool keyword. When we later fix altivec.h to not define them in the first place, this ordering requirement will no longer exist. While testing, I discovered a couple stray instances of "vector" that should have been "__vector" in these headers. Fixes for those are included in this patch. I also updated the gcc.target/powerpc/powerpc.exp file to allow C++ tests to be placed in that directory (with a *.C suffix). Bootstrapped and tested on powerpc64le-linux-gnu with no regressions. Is this okay for trunk? Thanks, Bill [gcc] 2018-04-02 Bill Schmidt * config/rs6000/emmintrin.h (_mm_cvtpd_epi32): Use __vector rather than vector. (_mm_cvtpd_ps): Likewise. (_mm_cvttpd_epi32): Likewise. * config/rs6000/mmintrin.h (_mm_unpacklo_pi8): Likewise. * config/rs6000/xmmintrin.h: For strict-ANSI C++ or C11, undefine vector, pixel, and bool following altivec.h include. [gcc/testsuite] 2018-04-02 Bill Schmidt * gcc.target/powerpc/powerpc.exp: Add .C suffix for main loop. * gcc.target/powerpc/undef-bool.C: New file. * gcc.target/powerpc/undef-bool.c: New file. Index: gcc/config/rs6000/emmintrin.h =================================================================== --- gcc/config/rs6000/emmintrin.h (revision 258958) +++ gcc/config/rs6000/emmintrin.h (working copy) @@ -885,7 +885,7 @@ _mm_cvtpd_epi32 (__m128d __A) #ifdef _ARCH_PWR8 temp = vec_mergeo (temp, temp); - result = (__v4si)vec_vpkudum ((vector long)temp, (vector long)vzero); + result = (__v4si)vec_vpkudum ((__vector long)temp, (__vector long)vzero); #else { const __v16qu pkperm = {0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0a, 0x0b, @@ -919,7 +919,7 @@ _mm_cvtpd_ps (__m128d __A) #ifdef _ARCH_PWR8 temp = vec_mergeo (temp, temp); - result = (__v4sf)vec_vpkudum ((vector long)temp, (vector long)vzero); + result = (__v4sf)vec_vpkudum ((__vector long)temp, (__vector long)vzero); #else { const __v16qu pkperm = {0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0a, 0x0b, @@ -947,7 +947,7 @@ _mm_cvttpd_epi32 (__m128d __A) #ifdef _ARCH_PWR8 temp = vec_mergeo (temp, temp); - result = (__v4si)vec_vpkudum ((vector long)temp, (vector long)vzero); + result = (__v4si)vec_vpkudum ((__vector long)temp, (__vector long)vzero); #else { const __v16qu pkperm = {0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0a, 0x0b, Index: gcc/config/rs6000/mmintrin.h =================================================================== --- gcc/config/rs6000/mmintrin.h (revision 258958) +++ gcc/config/rs6000/mmintrin.h (working copy) @@ -317,7 +317,7 @@ _mm_unpacklo_pi8 (__m64 __m1, __m64 __m2) a = (__vector unsigned char)vec_splats (__m1); b = (__vector unsigned char)vec_splats (__m2); c = vec_mergel (a, b); - return (__builtin_unpack_vector_int128 ((vector __int128_t)c, 1)); + return (__builtin_unpack_vector_int128 ((__vector __int128_t)c, 1)); #else __m64_union m1, m2, res; Index: gcc/config/rs6000/xmmintrin.h =================================================================== --- gcc/config/rs6000/xmmintrin.h (revision 258958) +++ gcc/config/rs6000/xmmintrin.h (working copy) @@ -58,6 +58,18 @@ #define _XMMINTRIN_H_INCLUDED #include + +/* Avoid collisions between altivec.h and strict adherence to C++ and + C11 standards. This should eventually be done inside altivec.h itself, + but only after testing a full distro build. */ +#if defined(__STRICT_ANSI__) && (defined(__cplusplus) || \ + (defined(__STDC_VERSION__) && \ + __STDC_VERSION__ >= 201112L)) +#undef vector +#undef pixel +#undef bool +#endif + #include /* We need type definitions from the MMX header file. */ Index: gcc/testsuite/gcc.target/powerpc/powerpc.exp =================================================================== --- gcc/testsuite/gcc.target/powerpc/powerpc.exp (revision 258958) +++ gcc/testsuite/gcc.target/powerpc/powerpc.exp (working copy) @@ -35,7 +35,7 @@ if ![info exists DEFAULT_CFLAGS] then { dg-init # Main loop. -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \ +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \ "" $DEFAULT_CFLAGS set SAVRES_TEST_OPTS [list -Os -O2 {-Os -mno-multiple} {-O2 -mno-multiple}] Index: gcc/testsuite/gcc.target/powerpc/undef-bool.C =================================================================== --- gcc/testsuite/gcc.target/powerpc/undef-bool.C (nonexistent) +++ gcc/testsuite/gcc.target/powerpc/undef-bool.C (working copy) @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=c++11 -DNO_WARN_X86_INTRINSICS" } */ + +/* Test to ensure that "bool" gets undef'd in xmmintrin.h when + we require strict ANSI. */ + +#include + +bool foo (int x) +{ + return x == 2; +} + Index: gcc/testsuite/gcc.target/powerpc/undef-bool.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/undef-bool.c (nonexistent) +++ gcc/testsuite/gcc.target/powerpc/undef-bool.c (working copy) @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=c11 -DNO_WARN_X86_INTRINSICS" } */ + +/* Test to ensure that "bool" gets undef'd in xmmintrin.h when + we require strict ANSI. Subsequent use of bool needs stdbool.h. + altivec.h should eventually avoid defining bool, vector, and + pixel, following distro testing. */ + +#include + +bool foo (int x) /* { dg-error "unknown type name 'bool'; did you mean '_Bool'?" } */ +{ + return x == 2; +} +