From patchwork Wed Jan 18 09:02:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 1728079 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=LADwAxch; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Nxftk6ZrBz23gM for ; Wed, 18 Jan 2023 20:03:24 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D99533858401 for ; Wed, 18 Jan 2023 09:03:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D99533858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674032601; bh=tSM8vMxfNy0qUC7fz+lZRdWeNUT/PecU2kxjICPsqKk=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=LADwAxchM7mDDRxwrXylrmPI8xxFLVde4I8uX780Bs47qXS3ftkp74uF93H6h6b1X Y7dlY1LUCypAGTgBj1l8iZc+209Jl7v9Qxgr2eYFOiIvin6N6+gclaDgCBxO6is/ng nwMtBslBYNQW9NaBRtq+2t9auDfz44vTSfy8jS10= 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 990173858D28 for ; Wed, 18 Jan 2023 09:02:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 990173858D28 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30I8Id8h012997; Wed, 18 Jan 2023 09:02:56 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n6d570vav-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Jan 2023 09:02:56 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 30I8Idds013063; Wed, 18 Jan 2023 09:02:55 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n6d570va7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Jan 2023 09:02:55 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30I7mBP3016548; Wed, 18 Jan 2023 09:02:53 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma02fra.de.ibm.com (PPS) with ESMTPS id 3n3m16kn1r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Jan 2023 09:02:53 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30I92oG950594246 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jan 2023 09:02:50 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C3BE320043; Wed, 18 Jan 2023 09:02:50 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ACD732004B; Wed, 18 Jan 2023 09:02:48 +0000 (GMT) Received: from [9.197.238.43] (unknown [9.197.238.43]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 18 Jan 2023 09:02:48 +0000 (GMT) Message-ID: <130a6f1b-9089-8cdc-8e0c-0870139df7c7@linux.ibm.com> Date: Wed, 18 Jan 2023 17:02:47 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH 2/2] rs6000: Refactor genfusion.pl a bit further Content-Language: en-US To: GCC Patches Cc: Segher Boessenkool , David Edelsohn , Peter Bergner References: <55027326-ffe1-87e8-9e4b-08535425afdd@linux.ibm.com> In-Reply-To: <55027326-ffe1-87e8-9e4b-08535425afdd@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ucNJ-LNK9xKSwRf9VfCZO59FYDzcVd6c X-Proofpoint-GUID: R-NqsDy1KPO1Yhzhtu5Xj1K-uLlrgSfP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-18_03,2023-01-17_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 lowpriorityscore=0 mlxscore=0 adultscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301180078 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, SCC_10_SHORT_WORD_LINES, SCC_20_SHORT_WORD_LINES, SCC_5_SHORT_WORD_LINES, 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: "Kewen.Lin via Gcc-patches" From: "Kewen.Lin" Reply-To: "Kewen.Lin" Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, To keep the previous refactoring patch not need to re-generate fusion.md and make the review easier, I didn't merge this patch into the previous one. But I think this one can help to make the subroutine gen_logical_addsubf_scalar more clear, by separating logical-logical and add-logical handlings into two different loops. It needs to regenerate fusion.md, since add-logical type definitions would have their own continuous area (it needs some rearrangments). Bootstrapped and regtested on powerpc64le-linux-gnu P10. Any comments are highly appreciated. BR, Kewen ----- gcc/ChangeLog: * config/rs6000/fusion.md : Regenerate. * config/rs6000/genfusion.pl (gen_logical_addsubf_scalar): Split logical-logical and add-logical handlings into two loops. --- gcc/config/rs6000/fusion.md | 288 ++++++++++++++++----------------- gcc/config/rs6000/genfusion.pl | 28 ++-- 2 files changed, 162 insertions(+), 154 deletions(-) -- 2.37.0 diff --git a/gcc/config/rs6000/fusion.md b/gcc/config/rs6000/fusion.md index d45fb138a70..0427505b7f7 100644 --- a/gcc/config/rs6000/fusion.md +++ b/gcc/config/rs6000/fusion.md @@ -499,42 +499,6 @@ (define_insn "*fuse_xor_and" (set_attr "cost" "6") (set_attr "length" "8")]) -;; add-logical fusion pattern generated by gen_logical_addsubf -;; scalar add -> and -(define_insn "*fuse_add_and" - [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r") - (and:GPR (plus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r") - (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r")) - (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r"))) - (clobber (match_scratch:GPR 4 "=X,X,X,&r"))] - "(TARGET_P10_FUSION)" - "@ - add %3,%1,%0\;and %3,%3,%2 - add %3,%1,%0\;and %3,%3,%2 - add %3,%1,%0\;and %3,%3,%2 - add %4,%1,%0\;and %3,%4,%2" - [(set_attr "type" "fused_arith_logical") - (set_attr "cost" "6") - (set_attr "length" "8")]) - -;; add-logical fusion pattern generated by gen_logical_addsubf -;; scalar subf -> and -(define_insn "*fuse_subf_and" - [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r") - (and:GPR (minus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r") - (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r")) - (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r"))) - (clobber (match_scratch:GPR 4 "=X,X,X,&r"))] - "(TARGET_P10_FUSION)" - "@ - subf %3,%1,%0\;and %3,%3,%2 - subf %3,%1,%0\;and %3,%3,%2 - subf %3,%1,%0\;and %3,%3,%2 - subf %4,%1,%0\;and %3,%4,%2" - [(set_attr "type" "fused_arith_logical") - (set_attr "cost" "6") - (set_attr "length" "8")]) - ;; logical-logical fusion pattern generated by gen_logical_addsubf ;; scalar and -> andc (define_insn "*fuse_and_andc" @@ -967,42 +931,6 @@ (define_insn "*fuse_xor_nand" (set_attr "cost" "6") (set_attr "length" "8")]) -;; add-logical fusion pattern generated by gen_logical_addsubf -;; scalar add -> nand -(define_insn "*fuse_add_nand" - [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r") - (ior:GPR (not:GPR (plus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r") - (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r"))) - (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r")))) - (clobber (match_scratch:GPR 4 "=X,X,X,&r"))] - "(TARGET_P10_FUSION)" - "@ - add %3,%1,%0\;nand %3,%3,%2 - add %3,%1,%0\;nand %3,%3,%2 - add %3,%1,%0\;nand %3,%3,%2 - add %4,%1,%0\;nand %3,%4,%2" - [(set_attr "type" "fused_arith_logical") - (set_attr "cost" "6") - (set_attr "length" "8")]) - -;; add-logical fusion pattern generated by gen_logical_addsubf -;; scalar subf -> nand -(define_insn "*fuse_subf_nand" - [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r") - (ior:GPR (not:GPR (minus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r") - (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r"))) - (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r")))) - (clobber (match_scratch:GPR 4 "=X,X,X,&r"))] - "(TARGET_P10_FUSION)" - "@ - subf %3,%1,%0\;nand %3,%3,%2 - subf %3,%1,%0\;nand %3,%3,%2 - subf %3,%1,%0\;nand %3,%3,%2 - subf %4,%1,%0\;nand %3,%4,%2" - [(set_attr "type" "fused_arith_logical") - (set_attr "cost" "6") - (set_attr "length" "8")]) - ;; logical-logical fusion pattern generated by gen_logical_addsubf ;; scalar and -> nor (define_insn "*fuse_and_nor" @@ -1147,42 +1075,6 @@ (define_insn "*fuse_xor_nor" (set_attr "cost" "6") (set_attr "length" "8")]) -;; add-logical fusion pattern generated by gen_logical_addsubf -;; scalar add -> nor -(define_insn "*fuse_add_nor" - [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r") - (and:GPR (not:GPR (plus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r") - (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r"))) - (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r")))) - (clobber (match_scratch:GPR 4 "=X,X,X,&r"))] - "(TARGET_P10_FUSION)" - "@ - add %3,%1,%0\;nor %3,%3,%2 - add %3,%1,%0\;nor %3,%3,%2 - add %3,%1,%0\;nor %3,%3,%2 - add %4,%1,%0\;nor %3,%4,%2" - [(set_attr "type" "fused_arith_logical") - (set_attr "cost" "6") - (set_attr "length" "8")]) - -;; add-logical fusion pattern generated by gen_logical_addsubf -;; scalar subf -> nor -(define_insn "*fuse_subf_nor" - [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r") - (and:GPR (not:GPR (minus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r") - (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r"))) - (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r")))) - (clobber (match_scratch:GPR 4 "=X,X,X,&r"))] - "(TARGET_P10_FUSION)" - "@ - subf %3,%1,%0\;nor %3,%3,%2 - subf %3,%1,%0\;nor %3,%3,%2 - subf %3,%1,%0\;nor %3,%3,%2 - subf %4,%1,%0\;nor %3,%4,%2" - [(set_attr "type" "fused_arith_logical") - (set_attr "cost" "6") - (set_attr "length" "8")]) - ;; logical-logical fusion pattern generated by gen_logical_addsubf ;; scalar and -> or (define_insn "*fuse_and_or" @@ -1327,42 +1219,6 @@ (define_insn "*fuse_xor_or" (set_attr "cost" "6") (set_attr "length" "8")]) -;; add-logical fusion pattern generated by gen_logical_addsubf -;; scalar add -> or -(define_insn "*fuse_add_or" - [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r") - (ior:GPR (plus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r") - (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r")) - (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r"))) - (clobber (match_scratch:GPR 4 "=X,X,X,&r"))] - "(TARGET_P10_FUSION)" - "@ - add %3,%1,%0\;or %3,%3,%2 - add %3,%1,%0\;or %3,%3,%2 - add %3,%1,%0\;or %3,%3,%2 - add %4,%1,%0\;or %3,%4,%2" - [(set_attr "type" "fused_arith_logical") - (set_attr "cost" "6") - (set_attr "length" "8")]) - -;; add-logical fusion pattern generated by gen_logical_addsubf -;; scalar subf -> or -(define_insn "*fuse_subf_or" - [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r") - (ior:GPR (minus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r") - (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r")) - (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r"))) - (clobber (match_scratch:GPR 4 "=X,X,X,&r"))] - "(TARGET_P10_FUSION)" - "@ - subf %3,%1,%0\;or %3,%3,%2 - subf %3,%1,%0\;or %3,%3,%2 - subf %3,%1,%0\;or %3,%3,%2 - subf %4,%1,%0\;or %3,%4,%2" - [(set_attr "type" "fused_arith_logical") - (set_attr "cost" "6") - (set_attr "length" "8")]) - ;; logical-logical fusion pattern generated by gen_logical_addsubf ;; scalar and -> orc (define_insn "*fuse_and_orc" @@ -1651,6 +1507,150 @@ (define_insn "*fuse_xor_xor" (set_attr "cost" "6") (set_attr "length" "8")]) +;; add-logical fusion pattern generated by gen_logical_addsubf +;; scalar add -> and +(define_insn "*fuse_add_and" + [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r") + (and:GPR (plus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r") + (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r")) + (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r"))) + (clobber (match_scratch:GPR 4 "=X,X,X,&r"))] + "(TARGET_P10_FUSION)" + "@ + add %3,%1,%0\;and %3,%3,%2 + add %3,%1,%0\;and %3,%3,%2 + add %3,%1,%0\;and %3,%3,%2 + add %4,%1,%0\;and %3,%4,%2" + [(set_attr "type" "fused_arith_logical") + (set_attr "cost" "6") + (set_attr "length" "8")]) + +;; add-logical fusion pattern generated by gen_logical_addsubf +;; scalar subf -> and +(define_insn "*fuse_subf_and" + [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r") + (and:GPR (minus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r") + (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r")) + (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r"))) + (clobber (match_scratch:GPR 4 "=X,X,X,&r"))] + "(TARGET_P10_FUSION)" + "@ + subf %3,%1,%0\;and %3,%3,%2 + subf %3,%1,%0\;and %3,%3,%2 + subf %3,%1,%0\;and %3,%3,%2 + subf %4,%1,%0\;and %3,%4,%2" + [(set_attr "type" "fused_arith_logical") + (set_attr "cost" "6") + (set_attr "length" "8")]) + +;; add-logical fusion pattern generated by gen_logical_addsubf +;; scalar add -> nand +(define_insn "*fuse_add_nand" + [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r") + (ior:GPR (not:GPR (plus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r") + (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r"))) + (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r")))) + (clobber (match_scratch:GPR 4 "=X,X,X,&r"))] + "(TARGET_P10_FUSION)" + "@ + add %3,%1,%0\;nand %3,%3,%2 + add %3,%1,%0\;nand %3,%3,%2 + add %3,%1,%0\;nand %3,%3,%2 + add %4,%1,%0\;nand %3,%4,%2" + [(set_attr "type" "fused_arith_logical") + (set_attr "cost" "6") + (set_attr "length" "8")]) + +;; add-logical fusion pattern generated by gen_logical_addsubf +;; scalar subf -> nand +(define_insn "*fuse_subf_nand" + [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r") + (ior:GPR (not:GPR (minus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r") + (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r"))) + (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r")))) + (clobber (match_scratch:GPR 4 "=X,X,X,&r"))] + "(TARGET_P10_FUSION)" + "@ + subf %3,%1,%0\;nand %3,%3,%2 + subf %3,%1,%0\;nand %3,%3,%2 + subf %3,%1,%0\;nand %3,%3,%2 + subf %4,%1,%0\;nand %3,%4,%2" + [(set_attr "type" "fused_arith_logical") + (set_attr "cost" "6") + (set_attr "length" "8")]) + +;; add-logical fusion pattern generated by gen_logical_addsubf +;; scalar add -> nor +(define_insn "*fuse_add_nor" + [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r") + (and:GPR (not:GPR (plus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r") + (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r"))) + (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r")))) + (clobber (match_scratch:GPR 4 "=X,X,X,&r"))] + "(TARGET_P10_FUSION)" + "@ + add %3,%1,%0\;nor %3,%3,%2 + add %3,%1,%0\;nor %3,%3,%2 + add %3,%1,%0\;nor %3,%3,%2 + add %4,%1,%0\;nor %3,%4,%2" + [(set_attr "type" "fused_arith_logical") + (set_attr "cost" "6") + (set_attr "length" "8")]) + +;; add-logical fusion pattern generated by gen_logical_addsubf +;; scalar subf -> nor +(define_insn "*fuse_subf_nor" + [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r") + (and:GPR (not:GPR (minus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r") + (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r"))) + (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r")))) + (clobber (match_scratch:GPR 4 "=X,X,X,&r"))] + "(TARGET_P10_FUSION)" + "@ + subf %3,%1,%0\;nor %3,%3,%2 + subf %3,%1,%0\;nor %3,%3,%2 + subf %3,%1,%0\;nor %3,%3,%2 + subf %4,%1,%0\;nor %3,%4,%2" + [(set_attr "type" "fused_arith_logical") + (set_attr "cost" "6") + (set_attr "length" "8")]) + +;; add-logical fusion pattern generated by gen_logical_addsubf +;; scalar add -> or +(define_insn "*fuse_add_or" + [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r") + (ior:GPR (plus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r") + (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r")) + (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r"))) + (clobber (match_scratch:GPR 4 "=X,X,X,&r"))] + "(TARGET_P10_FUSION)" + "@ + add %3,%1,%0\;or %3,%3,%2 + add %3,%1,%0\;or %3,%3,%2 + add %3,%1,%0\;or %3,%3,%2 + add %4,%1,%0\;or %3,%4,%2" + [(set_attr "type" "fused_arith_logical") + (set_attr "cost" "6") + (set_attr "length" "8")]) + +;; add-logical fusion pattern generated by gen_logical_addsubf +;; scalar subf -> or +(define_insn "*fuse_subf_or" + [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r") + (ior:GPR (minus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r") + (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r")) + (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r"))) + (clobber (match_scratch:GPR 4 "=X,X,X,&r"))] + "(TARGET_P10_FUSION)" + "@ + subf %3,%1,%0\;or %3,%3,%2 + subf %3,%1,%0\;or %3,%3,%2 + subf %3,%1,%0\;or %3,%3,%2 + subf %4,%1,%0\;or %3,%4,%2" + [(set_attr "type" "fused_arith_logical") + (set_attr "cost" "6") + (set_attr "length" "8")]) + ;; logical-add fusion pattern generated by gen_logical_addsubf ;; scalar and -> add (define_insn "*fuse_and_add" diff --git a/gcc/config/rs6000/genfusion.pl b/gcc/config/rs6000/genfusion.pl index 487e662ce05..6002a3af578 100755 --- a/gcc/config/rs6000/genfusion.pl +++ b/gcc/config/rs6000/genfusion.pl @@ -335,22 +335,30 @@ sub gen_logical_addsubf_scalar my $constraint = 'r'; my @logicals = ( 'and', 'andc', 'eqv', 'nand', 'nor', 'or', 'orc', 'xor' ); + + # logical-logical + foreach my $outer_op ( @logicals ) { + foreach my $inner_op ( @logicals ) { + my $exp = logical_addsubf_make_exp ($outer_op, $inner_op, $mode, + $pred, $constraint); + logical_addsubf_emit_define ('logical-logical', 'scalar', $outer_op, + $inner_op, $mode, $pred, $constraint, + $exp, $fuse_type); + } + } + # logical ops which can fuse with add/subf/rsubf my @logicals2 = ( 'and', 'nand', 'nor', 'or' ); my @add_subf = ( 'add', 'subf' ); - # {logical, add}-logical - foreach my $outer_op ( @logicals ) { - foreach my $inner_op ( @logicals, @add_subf ) { - my $ftype = 'logical-logical'; - if (grep (/^$inner_op$/, @add_subf)) { - next unless grep (/^$outer_op$/, @logicals2); - $ftype = 'add-logical'; - } + # add-logical + foreach my $outer_op ( @logicals2 ) { + foreach my $inner_op ( @add_subf ) { my $exp = logical_addsubf_make_exp ($outer_op, $inner_op, $mode, $pred, $constraint); - logical_addsubf_emit_define ($ftype, 'scalar', $outer_op, $inner_op, - $mode, $pred, $constraint, $exp, $fuse_type); + logical_addsubf_emit_define ('add-logical', 'scalar', $outer_op, + $inner_op, $mode, $pred, $constraint, + $exp, $fuse_type); } }