From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 94E1C3858D32 for ; Wed, 19 Jul 2023 05:24:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 94E1C3858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36J5IJsC019286; Wed, 19 Jul 2023 05:24:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : subject : from : to : cc : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pp1; bh=tu199kIz8BNFdFLFZ9CCo07nemBKaBcQi4tDNXd3248=; b=U12ZfenaqTiMyCx1RO57jGOtLwsKCl8WTohorQFx0iAuVi0pjLYNTQZUb2mTx+Vx8z5h SuSSY/TB7CZrkuDqpTHCUN3OKlj4gTzVXgndLkguriAS6crlSAgmYFNu2UMdd3RIbuKI xdhb3+0As5AWYpp+77lAPEim7IRAZUtC9o168QMNJtCR3p70Y/S8PP0lvnrZU5w0juCp 8nmFWj53irYXwR0l5Ge8+3sOtRnhBWRteWrm4WCwnso9TIfJvoVqDPd1IhJH0H13aAMb 138Y7WlLC5c/ee0eiCMzmW/kFLgDKnnX93IfHJI6+cPWbmxhfWIpLgzW6AFLQu9qS3lS YQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rx9jgg2xx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Jul 2023 05:24:47 +0000 Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36J5JtYM021871; Wed, 19 Jul 2023 05:24:47 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rx9jgg2xd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Jul 2023 05:24:46 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36J4KOD2029625; Wed, 19 Jul 2023 05:24:45 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3rv6smg3vb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Jul 2023 05:24:45 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36J5Oguo17433198 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Jul 2023 05:24:42 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49FF220040; Wed, 19 Jul 2023 05:24:42 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9C5E120043; Wed, 19 Jul 2023 05:24:40 +0000 (GMT) Received: from [9.200.144.106] (unknown [9.200.144.106]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 19 Jul 2023 05:24:40 +0000 (GMT) Message-ID: Date: Wed, 19 Jul 2023 13:24:40 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Ping [PATCH v7, rs6000] Implemented f[min/max]_optab by xs[min/max]dp [PR103605] Content-Language: en-US From: HAO CHEN GUI To: gcc-patches Cc: Segher Boessenkool , David , "Kewen.Lin" , Peter Bergner References: <1a6959ac-53c5-070b-e600-6fc1bab56ae4@linux.ibm.com> In-Reply-To: <1a6959ac-53c5-070b-e600-6fc1bab56ae4@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: UlKwcC8mFG1YuylcAkv1ws9wqnZFtLCW X-Proofpoint-GUID: WqSERSnfv3ED8Kv2AKWbFdI_WZsl9_q7 Content-Transfer-Encoding: 8bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-19_02,2023-07-18_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 adultscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307190047 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi, As the ticket(PR107013, adding fmin/max to RTL code) is suspended, I ping this patch. The unspec of fmin/max can be replaced with corresponding RTL code after that ticket is fixed. https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602181.html Thanks Gui Haochen 在 2022/9/26 11:35, HAO CHEN GUI 写道: > Hi, > This patch implements optab f[min/max]_optab by xs[min/max]dp on rs6000. > Tests show that outputs of xs[min/max]dp are consistent with the standard > of C99 fmin/max. > > This patch also binds __builtin_vsx_xs[min/max]dp to fmin/max instead > of smin/max when fast-math is not set. While fast-math is set, xs[min/max]dp > are folded to MIN/MAX_EXPR in gimple, and finally expanded to smin/max. > > Bootstrapped and tested on ppc64 Linux BE and LE with no regressions. > Is this okay for trunk? Any recommendations? Thanks a lot. > > ChangeLog > 2022-09-26 Haochen Gui > > gcc/ > PR target/103605 > * config/rs6000/rs6000-builtin.cc (rs6000_gimple_fold_builtin): Gimple > fold RS6000_BIF_XSMINDP and RS6000_BIF_XSMAXDP when fast-math is set. > * config/rs6000/rs6000.md (FMINMAX): New int iterator. > (minmax_op): New int attribute. > (UNSPEC_FMAX, UNSPEC_FMIN): New unspecs. > (f3): New pattern by UNSPEC_FMAX and UNSPEC_FMIN. > * config/rs6000/rs6000-builtins.def (__builtin_vsx_xsmaxdp): Set > pattern to fmaxdf3. > (__builtin_vsx_xsmindp): Set pattern to fmindf3. > > gcc/testsuite/ > PR target/103605 > * gcc.dg/powerpc/pr103605.h: New. > * gcc.dg/powerpc/pr103605-1.c: New. > * gcc.dg/powerpc/pr103605-2.c: New. > > patch.diff > diff --git a/gcc/config/rs6000/rs6000-builtin.cc b/gcc/config/rs6000/rs6000-builtin.cc > index e925ba9fad9..944ae9fe55c 100644 > --- a/gcc/config/rs6000/rs6000-builtin.cc > +++ b/gcc/config/rs6000/rs6000-builtin.cc > @@ -1588,6 +1588,8 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi) > gimple_set_location (g, gimple_location (stmt)); > gsi_replace (gsi, g, true); > return true; > + /* fold into MIN_EXPR when fast-math is set. */ > + case RS6000_BIF_XSMINDP: > /* flavors of vec_min. */ > case RS6000_BIF_XVMINDP: > case RS6000_BIF_XVMINSP: > @@ -1614,6 +1616,8 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi) > gimple_set_location (g, gimple_location (stmt)); > gsi_replace (gsi, g, true); > return true; > + /* fold into MAX_EXPR when fast-math is set. */ > + case RS6000_BIF_XSMAXDP: > /* flavors of vec_max. */ > case RS6000_BIF_XVMAXDP: > case RS6000_BIF_XVMAXSP: > diff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def > index f4a9f24bcc5..8b735493b40 100644 > --- a/gcc/config/rs6000/rs6000-builtins.def > +++ b/gcc/config/rs6000/rs6000-builtins.def > @@ -1613,10 +1613,10 @@ > XSCVSPDP vsx_xscvspdp {} > > const double __builtin_vsx_xsmaxdp (double, double); > - XSMAXDP smaxdf3 {} > + XSMAXDP fmaxdf3 {} > > const double __builtin_vsx_xsmindp (double, double); > - XSMINDP smindf3 {} > + XSMINDP fmindf3 {} > > const double __builtin_vsx_xsrdpi (double); > XSRDPI vsx_xsrdpi {} > diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md > index bf85baa5370..ae0dd98f0f9 100644 > --- a/gcc/config/rs6000/rs6000.md > +++ b/gcc/config/rs6000/rs6000.md > @@ -158,6 +158,8 @@ (define_c_enum "unspec" > UNSPEC_HASHCHK > UNSPEC_XXSPLTIDP_CONST > UNSPEC_XXSPLTIW_CONST > + UNSPEC_FMAX > + UNSPEC_FMIN > ]) > > ;; > @@ -5341,6 +5343,22 @@ (define_insn_and_split "*s3_fpr" > DONE; > }) > > + > +(define_int_iterator FMINMAX [UNSPEC_FMAX UNSPEC_FMIN]) > + > +(define_int_attr minmax_op [(UNSPEC_FMAX "max") > + (UNSPEC_FMIN "min")]) > + > +(define_insn "f3" > + [(set (match_operand:SFDF 0 "vsx_register_operand" "=wa") > + (unspec:SFDF [(match_operand:SFDF 1 "vsx_register_operand" "wa") > + (match_operand:SFDF 2 "vsx_register_operand" "wa")] > + FMINMAX))] > + "TARGET_VSX && !flag_finite_math_only" > + "xsdp %x0,%x1,%x2" > + [(set_attr "type" "fp")] > +) > + > (define_expand "movcc" > [(set (match_operand:GPR 0 "gpc_reg_operand") > (if_then_else:GPR (match_operand 1 "comparison_operator") > diff --git a/gcc/testsuite/gcc.target/powerpc/pr103605-1.c b/gcc/testsuite/gcc.target/powerpc/pr103605-1.c > new file mode 100644 > index 00000000000..923deec6a1e > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr103605-1.c > @@ -0,0 +1,7 @@ > +/* { dg-do compile } */ > +/* { dg-require-effective-target powerpc_vsx_ok } */ > +/* { dg-options "-O2 -mvsx" } */ > +/* { dg-final { scan-assembler-times {\mxsmaxdp\M} 3 } } */ > +/* { dg-final { scan-assembler-times {\mxsmindp\M} 3 } } */ > + > +#include "pr103605.h" > diff --git a/gcc/testsuite/gcc.target/powerpc/pr103605-2.c b/gcc/testsuite/gcc.target/powerpc/pr103605-2.c > new file mode 100644 > index 00000000000..f50fe9468f5 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr103605-2.c > @@ -0,0 +1,9 @@ > +/* { dg-do compile } */ > +/* { dg-require-effective-target powerpc_vsx_ok } */ > +/* { dg-options "-O2 -mvsx -ffast-math" } */ > +/* { dg-final { scan-assembler-times {\mxsmaxcdp\M} 3 { target has_arch_pwr9 } } } */ > +/* { dg-final { scan-assembler-times {\mxsmincdp\M} 3 { target has_arch_pwr9 } } } */ > +/* { dg-final { scan-assembler-times {\mxsmaxdp\M} 3 { target { ! has_arch_pwr9 } } } } */ > +/* { dg-final { scan-assembler-times {\mxsmindp\M} 3 { target { ! has_arch_pwr9 } } } } */ > + > +#include "pr103605.h" > diff --git a/gcc/testsuite/gcc.target/powerpc/pr103605.h b/gcc/testsuite/gcc.target/powerpc/pr103605.h > new file mode 100644 > index 00000000000..c99dfe6d7eb > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr103605.h > @@ -0,0 +1,31 @@ > +#include > + > +double test1 (double d0, double d1) > +{ > + return fmin (d0, d1); > +} > + > +float test2 (float d0, float d1) > +{ > + return fmin (d0, d1); > +} > + > +double test3 (double d0, double d1) > +{ > + return fmax (d0, d1); > +} > + > +float test4 (float d0, float d1) > +{ > + return fmax (d0, d1); > +} > + > +double test5 (double d0, double d1) > +{ > + return __builtin_vsx_xsmindp (d0, d1); > +} > + > +double test6 (double d0, double d1) > +{ > + return __builtin_vsx_xsmaxdp (d0, d1); > +} >