From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 4D5A33857C44 for ; Wed, 2 Sep 2020 02:00:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4D5A33857C44 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0821X2AL140922; Tue, 1 Sep 2020 22:00:23 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 339ybdbq9m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Sep 2020 22:00:23 -0400 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 0821Yket147893; Tue, 1 Sep 2020 22:00:23 -0400 Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0b-001b2d01.pphosted.com with ESMTP id 339ybdbq9b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Sep 2020 22:00:23 -0400 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0821rPcO014800; Wed, 2 Sep 2020 02:00:22 GMT Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by ppma02wdc.us.ibm.com with ESMTP id 337en9mch3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Sep 2020 02:00:22 +0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 08220Mnc55443880 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 2 Sep 2020 02:00:22 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EAA68124066; Wed, 2 Sep 2020 02:00:21 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8EE84124052; Wed, 2 Sep 2020 02:00:21 +0000 (GMT) Received: from sig-9-65-236-202.ibm.com (unknown [9.65.236.202]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 2 Sep 2020 02:00:21 +0000 (GMT) Message-ID: <15c6036f67ae9d5c516c9de8506bacc36f1af4f6.camel@vnet.ibm.com> Subject: [PATCH, rs6000] Fix Vector long long subtype (PR96139) From: will schmidt To: gcc-patches@gcc.gnu.org, Segher Boessenkool , David Edelsohn Date: Tue, 01 Sep 2020 21:00:20 -0500 Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-8.el7) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-09-01_10:2020-09-01, 2020-09-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 malwarescore=0 suspectscore=4 mlxscore=0 mlxlogscore=999 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009020011 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2020 02:00:26 -0000 Hi, This corrects an issue with the powerpc vector long long subtypes. As reported by SjMunroe in PR96139. When building some code with -Wall and attempting to print an element of a "long long vector" with a long long printf format string, we will report a error because the vector sub-type was improperly defined as int. When defining a V2DI_type_node we use a TARGET_POWERPC64 ternary to define the V2DI_type_node with "vector long" or "vector long long". We also need to specify the proper sub-type when we define the type. This has been successfully regtested on assorted power7,power8, power8 targets. Another sniff test in the queue to verify a last minute testcase tweak. OK for trunk? Thanks -Will PR target/96139 2020-09-01 Will Schmidt gcc/Changelog: * config/rs6000/rs6000-call.c (rs6000_init_builtin): Update V2DI_type_node and unsigned_V2DI_type_node definitions. gcc/testsuite/Changelog: * testsuite/gcc.target/powerpc/pr96139-a.c: New test. * testsuite/gcc.target/powerpc/pr96139-b.c: New test. * testsuite/gcc.target/powerpc/pr96139-c.c: New test. diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c index ff4c2537fada..354cac575cc6 100644 --- a/gcc/config/rs6000/rs6000-call.c +++ b/gcc/config/rs6000/rs6000-call.c @@ -12511,13 +12511,16 @@ rs6000_init_builtins (void) if (TARGET_DEBUG_BUILTIN) fprintf (stderr, "rs6000_init_builtins%s%s\n", (TARGET_ALTIVEC) ? ", altivec" : "", (TARGET_VSX) ? ", vsx" : ""); - V2DI_type_node = rs6000_vector_type (TARGET_POWERPC64 ? "__vector long" - : "__vector long long", - intDI_type_node, 2); + V2DI_type_node + = rs6000_vector_type (TARGET_POWERPC64 + ? "__vector long" : "__vector long long", + TARGET_POWERPC64 + ? long_long_integer_type_node : intDI_type_node, + 2); V2DF_type_node = rs6000_vector_type ("__vector double", double_type_node, 2); V4SI_type_node = rs6000_vector_type ("__vector signed int", intSI_type_node, 4); V4SF_type_node = rs6000_vector_type ("__vector float", float_type_node, 4); V8HI_type_node = rs6000_vector_type ("__vector signed short", @@ -12529,14 +12532,18 @@ rs6000_init_builtins (void) unsigned_intQI_type_node, 16); unsigned_V8HI_type_node = rs6000_vector_type ("__vector unsigned short", unsigned_intHI_type_node, 8); unsigned_V4SI_type_node = rs6000_vector_type ("__vector unsigned int", unsigned_intSI_type_node, 4); - unsigned_V2DI_type_node = rs6000_vector_type (TARGET_POWERPC64 - ? "__vector unsigned long" - : "__vector unsigned long long", - unsigned_intDI_type_node, 2); + unsigned_V2DI_type_node + = rs6000_vector_type (TARGET_POWERPC64 + ? "__vector unsigned long" + : "__vector unsigned long long", + TARGET_POWERPC64 + ? long_long_unsigned_type_node + : unsigned_intDI_type_node, + 2); opaque_V4SI_type_node = build_opaque_vector_type (intSI_type_node, 4); const_str_type_node = build_pointer_type (build_qualified_type (char_type_node, diff --git a/gcc/testsuite/gcc.target/powerpc/pr96139-a.c b/gcc/testsuite/gcc.target/powerpc/pr96139-a.c new file mode 100644 index 000000000000..37820b1809ba --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr96139-a.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -m32 " } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-require-effective-target powerpc_altivec_ok } */ + +#include +#include + +void +try_printing_longlong_a ( + __vector signed char cval, + __vector signed int ival, + __vector signed long long int llval, + int x, int y, int z) +{ + printf (" %016llx \n", llval[x]); + printf (" %016x \n", ival[z]); + printf (" %c \n", cval[y]); +} + +void +try_printing_unsigned_longlong_a ( + __vector unsigned char cval, + __vector unsigned int ival, + __vector unsigned long long int llval, + int x, int y, int z) +{ + printf (" %016llx \n", llval[x]); + printf (" %016x \n", ival[z]); + printf (" %c \n", cval[y]); +} + diff --git a/gcc/testsuite/gcc.target/powerpc/pr96139-b.c b/gcc/testsuite/gcc.target/powerpc/pr96139-b.c new file mode 100644 index 000000000000..7fac6901790e --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr96139-b.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -m64 " } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-require-effective-target powerpc_altivec_ok } */ + +#include +#include + +void +try_printing_longlong_a ( + __vector signed char cval, + __vector signed int ival, + __vector signed long long int llval, + int x, int y, int z) +{ + printf (" %016llx \n", llval[x]); + printf (" %016x \n", ival[z]); + printf (" %c \n", cval[y]); +} + + +void +try_printing_unsigned_longlong_a ( + __vector unsigned char cval, + __vector unsigned int ival, + __vector unsigned long long int llval, + int x, int y, int z) +{ + printf (" %016llx \n", llval[x]); + printf (" %016x \n", ival[z]); + printf (" %c \n", cval[y]); +} diff --git a/gcc/testsuite/gcc.target/powerpc/pr96139-c.c b/gcc/testsuite/gcc.target/powerpc/pr96139-c.c new file mode 100644 index 000000000000..2464b8da4f71 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr96139-c.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -Wall" } */ +/* { dg-require-effective-target powerpc_altivec_ok } */ + +/* + * Based on test created by sjmunroe for pr96139 + */ + +#include +#include + +volatile vector long long llfoo; + +void +print_v2xint64_b () { + printf (" %016llx \n", llfoo[0]); + printf (" %016llx \n", llfoo[1]); +} + +int +main() { +llfoo[0]=12345678; +llfoo[1]=34567890; +print_v2xint64_b(); +return 0; +}