From patchwork Fri Sep 24 15:20:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 45418 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B534D3858034 for ; Fri, 24 Sep 2021 15:21:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B534D3858034 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1632496887; bh=IWSI2GGR1g6Rlh6Uv5Eh3Mz1jt59FyU5G5zNWls7gPQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=U6OIOUejTjYZIUYan+Nt8zfBYzJDn1tMmxqP1n27eftYxIb7P3MFYxReSuY5CwypS zE8OZOwnfngDR4mh5JrTbe4m19x6uAABo3MT7ZQKcJg1Ne8IMHm+SaXwaV1ZTMoMBh fRZvLJFe7sL0EHpPOIGv/P+GDBJzKLdEgzQhgBpU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 9EB653858403 for ; Fri, 24 Sep 2021 15:20:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9EB653858403 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18OFC87H020732; Fri, 24 Sep 2021 11:20:55 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3b9f6cksb4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Sep 2021 11:20:55 -0400 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 18OElVaN015811; Fri, 24 Sep 2021 11:20:54 -0400 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com with ESMTP id 3b9f6cksas-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Sep 2021 11:20:54 -0400 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 18OFIA2b019334; Fri, 24 Sep 2021 15:20:53 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma01wdc.us.ibm.com with ESMTP id 3b93g9f0mj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Sep 2021 15:20:53 +0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 18OFKqI046989798 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Sep 2021 15:20:52 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 705856A047; Fri, 24 Sep 2021 15:20:52 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4B3596A04D; Fri, 24 Sep 2021 15:20:47 +0000 (GMT) Received: from Bills-MacBook-Pro.local (unknown [9.211.85.128]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 24 Sep 2021 15:20:47 +0000 (GMT) To: GCC Patches Subject: [PATCH] rs6000: Fix vec_cpsgn parameter order (PR101985) Message-ID: <0f9bde3b-e6f3-1d4f-cf76-6ac345bfe07d@linux.ibm.com> Date: Fri, 24 Sep 2021 10:20:46 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 Content-Language: en-GB X-TM-AS-GCONF: 00 X-Proofpoint-GUID: hOZYi7Qt5MJWdhq5LFOylF0Y0SY-W0bl X-Proofpoint-ORIG-GUID: KyRzAkqPuzgmFc5omJSffn11j0gxPrqU X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-24_04,2021-09-24_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 mlxlogscore=999 impostorscore=0 spamscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 clxscore=1015 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2109240097 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-Patchwork-Original-From: Bill Schmidt via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: wschmidt@linux.ibm.com Cc: David Edelsohn , Segher Boessenkool Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! This fixes a bug reported in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101985. The vec_cpsgn built-in function API differs in argument order from the copysign3 convention. Currently that pattern is incorrctly used to implement vec_cpsgn. Fix that while leaving the existing pattern in place to implement copysignf for vector modes. Part of the fix when using the new built-in support requires an adjustment to a pending patch that replaces much of altivec.h with an automatically generated file. So that adjustment will be coming later... Also fix a bug in the new built-in overload infrastructure where we were using the VSX form of the VEC_COPYSIGN built-in when we should default to the VMX form. Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no regressions. Is this okay for trunk? Thanks! Bill 2021-09-24 Bill Schmidt gcc/ PR target/101985 * config/rs6000/altivec.h (vec_cpsgn): Adjust. * config/rs6000/rs6000-overload.def (VEC_COPYSIGN): Use SKIP to avoid generating an automatic #define of vec_cpsgn. Use the correct built-in for V4SFmode that doesn't depend on VSX. gcc/testsuite/ PR target/101985 * gcc.target/powerpc/pr101985.c: New. --- gcc/config/rs6000/altivec.h | 2 +- gcc/config/rs6000/rs6000-overload.def | 4 ++-- gcc/testsuite/gcc.target/powerpc/pr101985-1.c | 18 ++++++++++++++++++ gcc/testsuite/gcc.target/powerpc/pr101985-2.c | 18 ++++++++++++++++++ 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr101985-1.c create mode 100644 gcc/testsuite/gcc.target/powerpc/pr101985-2.c diff --git a/gcc/config/rs6000/altivec.h b/gcc/config/rs6000/altivec.h index 5b631c7ebaf..ea72c9c1789 100644 --- a/gcc/config/rs6000/altivec.h +++ b/gcc/config/rs6000/altivec.h @@ -129,7 +129,7 @@ #define vec_vcfux __builtin_vec_vcfux #define vec_cts __builtin_vec_cts #define vec_ctu __builtin_vec_ctu -#define vec_cpsgn __builtin_vec_copysign +#define vec_cpsgn(x,y) __builtin_vec_copysign(y,x) #define vec_double __builtin_vec_double #define vec_doublee __builtin_vec_doublee #define vec_doubleo __builtin_vec_doubleo diff --git a/gcc/config/rs6000/rs6000-overload.def b/gcc/config/rs6000/rs6000-overload.def index 141f831e2c0..4f583312f36 100644 --- a/gcc/config/rs6000/rs6000-overload.def +++ b/gcc/config/rs6000/rs6000-overload.def @@ -1154,9 +1154,9 @@ vus __builtin_vec_convert_4f32_8f16 (vf, vf); CONVERT_4F32_8F16 -[VEC_COPYSIGN, vec_cpsgn, __builtin_vec_copysign] +[VEC_COPYSIGN, SKIP, __builtin_vec_copysign] vf __builtin_vec_copysign (vf, vf); - CPSGNSP + COPYSIGN_V4SF vd __builtin_vec_copysign (vd, vd); CPSGNDP diff --git a/gcc/testsuite/gcc.target/powerpc/pr101985-1.c b/gcc/testsuite/gcc.target/powerpc/pr101985-1.c new file mode 100644 index 00000000000..a1ec2d68d53 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr101985-1.c @@ -0,0 +1,18 @@ +/* PR target/101985 */ +/* { dg-do run } */ +/* { dg-require-effective-target vsx_hw } */ +/* { dg-options "-O2" } */ + +#include + +int +main (void) +{ + vector float a = { 1, 2, - 3, - 4}; + vector float b = {-10, 20, -30, 40}; + vector float c = { 10, 20, -30, -40}; + a = vec_cpsgn (a, b); + if (! vec_all_eq (a, c)) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/pr101985-2.c b/gcc/testsuite/gcc.target/powerpc/pr101985-2.c new file mode 100644 index 00000000000..71cc254c170 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr101985-2.c @@ -0,0 +1,18 @@ +/* PR target/101985 */ +/* { dg-do run } */ +/* { dg-require-effective-target vsx_hw } */ +/* { dg-options "-O2" } */ + +#include + +int +main (void) +{ + vector double a = { 1, -4}; + vector double b = { -10, 40}; + vector double c = { 10, -40}; + a = vec_cpsgn (a, b); + if (! vec_all_eq (a, c)) + __builtin_abort (); + return 0; +}