From patchwork Mon Jul 25 05:11:47 2022 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: 148 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:b5d6:b0:2b9:3548:2db5 with SMTP id v22csp1456641pxt; Sun, 24 Jul 2022 22:12:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tLewUSymCI3ajUY+FRWYxuEiuszUWIhtEYZteZ6qkNIowu7jT4iILxxWYYGFYlRt2M+o0K X-Received: by 2002:a17:907:7637:b0:72b:3a3b:7d68 with SMTP id jy23-20020a170907763700b0072b3a3b7d68mr8291871ejc.566.1658725963012; Sun, 24 Jul 2022 22:12:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658725963; cv=none; d=google.com; s=arc-20160816; b=x7h1nkotEzTf1959rIMsj+a1GUsMs7n0HluMpnSuOGR7O/RFttnXVH1I41v3HQZU8P +gpviam+rGDAubmnoQxX7OK42aJxeuAeI6hYVpupf0yPWHgTmoubKfRJnhLYBDxXnhZY psW68QBWts3ZiE14ZnmDHxzw1TFEyfkCXqNqU5ZcC9DfmIQ/0PLxPE8wfHlwmEURpfN2 1Vf2deYDU1SFnpJiAczZdE1iO/ERS0zmNrz29ntj30dB5NzXdkv0cg/wgnyGA55eXk2o VfNdix5MQ93t4Q/SHzAgducIyOpGT8TdUdG8Occ8AgJCkQIIhDk/GCByxI68iWxj5Psl FFEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:subject:to:content-language:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=PENpINMScAQNjJE9ZwSWH3mpV3W67GT5qOsu9suBg1k=; b=bIVjvbVGTHXb7KbDqhLAXb7eXLhsaEmZBPs1pUh4VPOYQagMENQ9fWA6vtuC5zEhQR 7kty5cw8JoI8/ZdyWmg95EwfBjIm/HyEI3RYM2oWsOmCgLLgA155dpYoosPvckTy5lbm 10zedpXkwH5gYELYL92Kyy7iQiVCn03vPMu7E27xTA3NNwoGeQma2uQziz/OFYmMZo6k 0H7SApC4Yf2zsavmvdCnniubCavGhMsc87dFPAa5q3Sg2DExo5X41uDKSnUT/6VxNq5T WdlpbMftX2zSHtu2s6oSjoOq70VttSdG1UJ/og/wVf/wjldNlOra2pUTZwhkrdMWJxRW FB0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=rTszBgZU; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id h7-20020a0564020e8700b0043bd454564dsi7453265eda.124.2022.07.24.22.12.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jul 2022 22:12:43 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=rTszBgZU; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9526B384146D for ; Mon, 25 Jul 2022 05:12:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9526B384146D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658725961; bh=PENpINMScAQNjJE9ZwSWH3mpV3W67GT5qOsu9suBg1k=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=rTszBgZUN1PhMU3hVSZDcg5qWSYDCKrkyGHttc5YJxetORzUSqsGOCGvcwnZmPLiX k+2NLkfnTsTA+UtPtrIEVGg0wuRfBtUdpn2QDCmI41sXbfO7AGZVijhLJT6uXXhEZu LBnRKX6n7tbaSEtyROarxe7TNa0TW5XhD8m03S1E= 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 61D0F3841442 for ; Mon, 25 Jul 2022 05:11:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 61D0F3841442 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26P4pljG016661; Mon, 25 Jul 2022 05:11:57 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hhmh7gh21-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Jul 2022 05:11:56 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26P4vexD022356; Mon, 25 Jul 2022 05:11:56 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hhmh7gh1e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Jul 2022 05:11:56 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26P56uDG001118; Mon, 25 Jul 2022 05:11:54 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma03ams.nl.ibm.com with ESMTP id 3hh6eugk9h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Jul 2022 05:11:53 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26P5Bob616712150 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 25 Jul 2022 05:11:50 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A29E152050; Mon, 25 Jul 2022 05:11:50 +0000 (GMT) Received: from [9.200.45.50] (unknown [9.200.45.50]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id EEEBC5204F; Mon, 25 Jul 2022 05:11:48 +0000 (GMT) Message-ID: Date: Mon, 25 Jul 2022 13:11:47 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-US To: gcc-patches Subject: [PATCH, rs6000] Add multiply-add expand pattern [PR103109] X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: FxOVGdFVIn4CrcPP8Bj7UVmvbEmYGDPV X-Proofpoint-GUID: AgEnheOwuZ73qfW56TnM0YBUAo4pgln7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-23_02,2022-07-21_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 phishscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207250022 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: HAO CHEN GUI via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: HAO CHEN GUI Cc: Peter Bergner , David , Segher Boessenkool Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1739300235587850530?= X-GMAIL-MSGID: =?utf-8?q?1739300235587850530?= Hi, This patch adds an expand and several insns for multiply-add with three 64bit operands. Bootstrapped and tested on powerpc64-linux BE and LE with no regressions. Is this okay for trunk? Any recommendations? Thanks a lot. ChangeLog 2022-07-22 Haochen Gui gcc/ PR target/103109 * config/rs6000/rs6000.md (maddditi4): New pattern for multiply-add. (madddi4_lowpart): New. (madddi4_lowpart_le): New. (madddi4_highpart): New. (madddi4_highpart_le): New. gcc/testsuite/ PR target/103109 * gcc.target/powerpc/pr103109.c: New. patch.diff diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index c55ee7e171a..4f3b56e103e 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -3226,6 +3226,97 @@ (define_insn "*maddld4" "maddld %0,%1,%2,%3" [(set_attr "type" "mul")]) +(define_expand "maddditi4" + [(set (match_operand:TI 0 "gpc_reg_operand") + (plus:TI + (mult:TI (any_extend:TI + (match_operand:DI 1 "gpc_reg_operand")) + (any_extend:TI + (match_operand:DI 2 "gpc_reg_operand"))) + (any_extend:TI + (match_operand:DI 3 "gpc_reg_operand"))))] + "TARGET_POWERPC64 && TARGET_MADDLD" +{ + rtx op0_lo = gen_rtx_SUBREG (DImode, operands[0], BYTES_BIG_ENDIAN ? 8 : 0); + rtx op0_hi = gen_rtx_SUBREG (DImode, operands[0], BYTES_BIG_ENDIAN ? 0 : 8); + + if (BYTES_BIG_ENDIAN) + { + emit_insn (gen_madddi4_lowpart (op0_lo, operands[1], operands[2], + operands[3])); + emit_insn (gen_madddi4_highpart (op0_hi, operands[1], operands[2], + operands[3])); + } + else + { + emit_insn (gen_madddi4_lowpart_le (op0_lo, operands[1], operands[2], + operands[3])); + emit_insn (gen_madddi4_highpart_le (op0_hi, operands[1], operands[2], + operands[3])); + } + DONE; +}) + +(define_insn "madddi4_lowpart" + [(set (match_operand:DI 0 "gpc_reg_operand" "=r") + (subreg:DI + (plus:TI + (mult:TI (any_extend:TI + (match_operand:DI 1 "gpc_reg_operand" "r")) + (any_extend:TI + (match_operand:DI 2 "gpc_reg_operand" "r"))) + (any_extend:TI + (match_operand:DI 3 "gpc_reg_operand" "r"))) + 8))] + "TARGET_POWERPC64 && TARGET_MADDLD && BYTES_BIG_ENDIAN" + "maddld %0,%1,%2,%3" + [(set_attr "type" "mul")]) + +(define_insn "madddi4_lowpart_le" + [(set (match_operand:DI 0 "gpc_reg_operand" "=r") + (subreg:DI + (plus:TI + (mult:TI (any_extend:TI + (match_operand:DI 1 "gpc_reg_operand" "r")) + (any_extend:TI + (match_operand:DI 2 "gpc_reg_operand" "r"))) + (any_extend:TI + (match_operand:DI 3 "gpc_reg_operand" "r"))) + 0))] + "TARGET_POWERPC64 && TARGET_MADDLD && !BYTES_BIG_ENDIAN" + "maddld %0,%1,%2,%3" + [(set_attr "type" "mul")]) + +(define_insn "madddi4_highpart" + [(set (match_operand:DI 0 "gpc_reg_operand" "=r") + (subreg:DI + (plus:TI + (mult:TI (any_extend:TI + (match_operand:DI 1 "gpc_reg_operand" "r")) + (any_extend:TI + (match_operand:DI 2 "gpc_reg_operand" "r"))) + (any_extend:TI + (match_operand:DI 3 "gpc_reg_operand" "r"))) + 0))] + "TARGET_POWERPC64 && TARGET_MADDLD && BYTES_BIG_ENDIAN" + "maddhd %0,%1,%2,%3" + [(set_attr "type" "mul")]) + +(define_insn "madddi4_highpart_le" + [(set (match_operand:DI 0 "gpc_reg_operand" "=r") + (subreg:DI + (plus:TI + (mult:TI (any_extend:TI + (match_operand:DI 1 "gpc_reg_operand" "r")) + (any_extend:TI + (match_operand:DI 2 "gpc_reg_operand" "r"))) + (any_extend:TI + (match_operand:DI 3 "gpc_reg_operand" "r"))) + 8))] + "TARGET_POWERPC64 && TARGET_MADDLD && !BYTES_BIG_ENDIAN" + "maddhd %0,%1,%2,%3" + [(set_attr "type" "mul")]) + (define_insn "udiv3" [(set (match_operand:GPR 0 "gpc_reg_operand" "=r") (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "r") diff --git a/gcc/testsuite/gcc.target/powerpc/pr103109.c b/gcc/testsuite/gcc.target/powerpc/pr103109.c new file mode 100644 index 00000000000..256e05d5677 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr103109.c @@ -0,0 +1,16 @@ +/* { dg-do compile { target { lp64 } } } */ +/* { dg-require-effective-target powerpc_p9modulo_ok } */ +/* { dg-options "-mdejagnu-cpu=power9 -O2" } */ +/* { dg-final { scan-assembler-times {\mmaddld\M} 2 } } */ +/* { dg-final { scan-assembler-times {\mmaddhd\M} 1 } } */ +/* { dg-final { scan-assembler-times {\mmaddhdu\M} 1 } } */ + +__int128 test (long a, long b, long c) +{ + return (__int128) a * (__int128) b + (__int128) c; +} + +unsigned __int128 testu (unsigned long a, unsigned long b, unsigned long c) +{ + return (unsigned __int128) a * (unsigned __int128) b + (unsigned __int128) c; +}