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 E9F60385840F; Fri, 3 Sep 2021 14:51:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E9F60385840F Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 183EWoVS104278; Fri, 3 Sep 2021 10:51:07 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3auh4d7g7q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 Sep 2021 10:51:07 -0400 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 183EWvAF104771; Fri, 3 Sep 2021 10:51:07 -0400 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0b-001b2d01.pphosted.com with ESMTP id 3auh4d7g7c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 Sep 2021 10:51:07 -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 183Ekpg8012883; Fri, 3 Sep 2021 14:51:06 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma01wdc.us.ibm.com with ESMTP id 3au6pjr88r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 Sep 2021 14:51:06 +0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 183Ep59g26542514 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 3 Sep 2021 14:51:05 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 40B426A054; Fri, 3 Sep 2021 14:51:05 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E6E096A04F; Fri, 3 Sep 2021 14:51:04 +0000 (GMT) Received: from Bills-MacBook-Pro.local (unknown [9.211.156.247]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 3 Sep 2021 14:51:04 +0000 (GMT) Reply-To: wschmidt@linux.ibm.com Subject: Re: Ping ^ 2: [PATCH] rs6000: Expand fmod and remainder when built with fast-math [PR97142] To: Xionghu Luo , will schmidt , gcc-patches@gcc.gnu.org Cc: segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org References: <20210416071007.78812-1-luoxhu@linux.ibm.com> <6d438971-4778-91cf-451c-a493b0cf9bdf@linux.ibm.com> <4ead69cf-daac-31bb-ddb5-d7b41cf298e2@linux.ibm.com> <2260972d-e44d-f084-69bb-2b7c96c00525@linux.ibm.com> From: Bill Schmidt Message-ID: <7b926ce0-16a8-43bf-8048-56f3d3eaf221@linux.ibm.com> Date: Fri, 3 Sep 2021 09:51:04 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-TM-AS-GCONF: 00 X-Proofpoint-GUID: f3TV_9g3QazcpeYL3rYmha7xclbzXyzM X-Proofpoint-ORIG-GUID: -aqUN4J1hIxJdIoOhVhQ526CmmiTcJrA X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-09-03_05:2021-09-03, 2021-09-03 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 adultscore=0 clxscore=1011 malwarescore=0 suspectscore=0 impostorscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2108310000 definitions=main-2109030090 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, RCVD_IN_MSPIKE_H4, 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-List-Received-Date: Fri, 03 Sep 2021 14:51:09 -0000 Hi Xionghu, This looks okay to me.  Recommend maintainers approve. Thanks! Bill On 9/2/21 9:31 PM, Xionghu Luo wrote: > Resend the patch that addressed Will's comments. > > > fmod/fmodf and remainder/remainderf could be expanded instead of library > call when fast-math build, which is much faster. > > fmodf: > fdivs f0,f1,f2 > friz f0,f0 > fnmsubs f1,f2,f0,f1 > > remainderf: > fdivs f0,f1,f2 > frin f0,f0 > fnmsubs f1,f2,f0,f1 > > SPEC2017 Ofast P8LE: 511.povray_r +1.14%, 526.blender_r +1.72% > > gcc/ChangeLog: > > 2021-09-03 Xionghu Luo > > PR target/97142 > * config/rs6000/rs6000.md (fmod3): New define_expand. > (remainder3): Likewise. > > gcc/testsuite/ChangeLog: > > 2021-09-03 Xionghu Luo > > PR target/97142 > * gcc.target/powerpc/pr97142.c: New test. > --- > gcc/config/rs6000/rs6000.md | 36 ++++++++++++++++++++++ > gcc/testsuite/gcc.target/powerpc/pr97142.c | 35 +++++++++++++++++++++ > 2 files changed, 71 insertions(+) > create mode 100644 gcc/testsuite/gcc.target/powerpc/pr97142.c > > diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md > index c8cdc42533c..84820d3b5cb 100644 > --- a/gcc/config/rs6000/rs6000.md > +++ b/gcc/config/rs6000/rs6000.md > @@ -4932,6 +4932,42 @@ (define_insn "fre" > [(set_attr "type" "fp") > (set_attr "isa" "*,")]) > > +(define_expand "fmod3" > + [(use (match_operand:SFDF 0 "gpc_reg_operand")) > + (use (match_operand:SFDF 1 "gpc_reg_operand")) > + (use (match_operand:SFDF 2 "gpc_reg_operand"))] > + "TARGET_HARD_FLOAT > + && TARGET_FPRND > + && flag_unsafe_math_optimizations" > +{ > + rtx div = gen_reg_rtx (mode); > + emit_insn (gen_div3 (div, operands[1], operands[2])); > + > + rtx friz = gen_reg_rtx (mode); > + emit_insn (gen_btrunc2 (friz, div)); > + > + emit_insn (gen_nfms4 (operands[0], operands[2], friz, operands[1])); > + DONE; > + }) > + > +(define_expand "remainder3" > + [(use (match_operand:SFDF 0 "gpc_reg_operand")) > + (use (match_operand:SFDF 1 "gpc_reg_operand")) > + (use (match_operand:SFDF 2 "gpc_reg_operand"))] > + "TARGET_HARD_FLOAT > + && TARGET_FPRND > + && flag_unsafe_math_optimizations" > +{ > + rtx div = gen_reg_rtx (mode); > + emit_insn (gen_div3 (div, operands[1], operands[2])); > + > + rtx frin = gen_reg_rtx (mode); > + emit_insn (gen_round2 (frin, div)); > + > + emit_insn (gen_nfms4 (operands[0], operands[2], frin, operands[1])); > + DONE; > + }) > + > (define_insn "*rsqrt2" > [(set (match_operand:SFDF 0 "gpc_reg_operand" "=,wa") > (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" ",wa")] > diff --git a/gcc/testsuite/gcc.target/powerpc/pr97142.c b/gcc/testsuite/gcc.target/powerpc/pr97142.c > new file mode 100644 > index 00000000000..e5306eb681b > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr97142.c > @@ -0,0 +1,35 @@ > +/* { dg-do compile } */ > +/* { dg-options "-Ofast" } */ > + > +#include > + > +float test1 (float x, float y) > +{ > + return fmodf (x, y); > +} > + > +double test2 (double x, double y) > +{ > + return fmod (x, y); > +} > + > +float test3 (float x, float y) > +{ > + return remainderf (x, y); > +} > + > +double test4 (double x, double y) > +{ > + return remainder (x, y); > +} > + > +/* { dg-final { scan-assembler-not {\mbl fmod\M} } } */ > +/* { dg-final { scan-assembler-not {\mbl fmodf\M} } } */ > +/* { dg-final { scan-assembler-not {\mbl remainder\M} } } */ > +/* { dg-final { scan-assembler-not {\mbl remainderf\M} } } */ > +/* { dg-final { scan-assembler-times {\mfdiv\M} 2 } } */ > +/* { dg-final { scan-assembler-times {\mfdivs\M} 2 } } */ > +/* { dg-final { scan-assembler-times {\mfnmsub\M} 2 } } */ > +/* { dg-final { scan-assembler-times {\mfnmsubs\M} 2 } } */ > +/* { dg-final { scan-assembler-times {\mfriz\M} 2 } } */ > +/* { dg-final { scan-assembler-times {\mfrin\M} 2 } } */