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: 45104 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2223475wrn; Wed, 18 Jan 2023 01:03:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXu7x2toaJ2EExsIn3uDH6qZkwJT8RfhMQphRJZixXjhZSuKsziCKhNl9k2mmsbF6DuT0+uP X-Received: by 2002:a17:906:848e:b0:818:3ef8:f2fc with SMTP id m14-20020a170906848e00b008183ef8f2fcmr6350921ejx.5.1674032627386; Wed, 18 Jan 2023 01:03:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674032627; cv=none; d=google.com; s=arc-20160816; b=UXk7fQOGM5+iY+XF78vJkBSDmEG9lJ0yWpS769hP7rMvIWRaNmRfmFciQ3JnDJYvqY hC4HfAANABNNP5QBwAHMp7TBMrDxzM2Chss+ZMWH48nDHWAfVIhd4hWVCyYHud4xTaST sWRr6IulMB9nlulcGeKL/LO49Wl/2540xT8kYQ0V7NgfmeGwxSY/YfFScGuju6YaRwAw fkKelRJZ5MN6t9ReJ3SmqmZQdhXKV7T+uSgsTeLauDN5C2tkGbVCzDOkglUKPrNSFj+i mDD+U6hpsHF79ZYXn6hjkeByIoWXNaER1ZYbCtkmrPfkJZh2abNqi0M8Q5jnLTrpu8Ot tXQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:in-reply-to:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=tSM8vMxfNy0qUC7fz+lZRdWeNUT/PecU2kxjICPsqKk=; b=wCkmK9qRznsNjZ3h7cDotCEF6fnD7dWQLlCFVKwm+MqTNXctTdeFPoiV9eSjvYb3zn rCBk4uw60stPxKRnnTvbnQmPkvAMM16/DIRcwDuufRrpdsVjP8c03QHrXPF+QJKmzGVp eMqWEKpbxm24ksFgK1861DzWElj5UkaLcFGb9ZXFhRfaWKf0mADnoJ91LWyO69RgU4YQ 6ZaO+AxgPElN/6rpD5c2Zu/6BCq3mC6d+2Jdqtqp4JV0EUbIgkQUAtEYpKLWAOUfVOP5 /RYhJI4NK+G/URvp5kl8iNxo/lhB6m0UWhp4j6el/xnXYpmse4z5IMBQmo9d2Yg4DOo2 Iudw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Angf2iiH; 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 hb44-20020a170907162c00b0084d4707b50bsi33799614ejc.698.2023.01.18.01.03.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 01:03:47 -0800 (PST) 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=Angf2iiH; 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 174B7385841D for ; Wed, 18 Jan 2023 09:03:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 174B7385841D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674032626; 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=Angf2iiHP9v3KXhZbWc6s52HEs/zY3r3q+ySQCH52kKZv5x9HUeY3D04BYHqY9qSz qBnuligOOgkxA6iqQor7EJPLZpdEwuoZEVLBAIpyufACDvuQRCZgpqIO/TMetQCj0E DH7FJXL6RoXQRlEb4PuOnJQ25/Pe6rOQOnlib+Jo= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755350436537422487?= X-GMAIL-MSGID: =?utf-8?q?1755350436537422487?= 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); } }