From patchwork Sun Jun 12 06:38:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takayuki 'January June' Suwa X-Patchwork-Id: 55038 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D028F38425B0 for ; Sun, 12 Jun 2022 06:45:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D028F38425B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1655016343; bh=Uk8w0egBeu0f2ByhWo15GbhsRxwadfeHAu7QjYq3+GY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=yNvLsGR+8vSBH7mRZvh7I4ZgIeKMHytCdnaJPoAPHvIF4c3T/bpNhLzOLTR3JWdEJ EHqAEer7+DgyLMt2/DJmY52jC08vwFlNPelnnCAv0HCenHkEz3vu1GI33XHqb+PHtc oX6/iEoPwWQwLz9AcqgO8B+y7DqX76CgrNw8GZnE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nh603-vm9.bullet.mail.ssk.yahoo.co.jp (nh603-vm9.bullet.mail.ssk.yahoo.co.jp [182.22.90.50]) by sourceware.org (Postfix) with SMTP id 9F765386F0F6 for ; Sun, 12 Jun 2022 06:43:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9F765386F0F6 Received: from [182.22.66.103] by nh603.bullet.mail.ssk.yahoo.co.jp with NNFMP; 12 Jun 2022 06:43:17 -0000 Received: from [182.22.91.205] by t601.bullet.mail.ssk.yahoo.co.jp with NNFMP; 12 Jun 2022 06:43:17 -0000 Received: from [127.0.0.1] by omp608.mail.ssk.yahoo.co.jp with NNFMP; 12 Jun 2022 06:43:17 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 907158.61775.bm@omp608.mail.ssk.yahoo.co.jp Received: (qmail 31832 invoked by alias); 12 Jun 2022 06:43:17 -0000 Received: from unknown (HELO ?192.168.2.3?) (175.177.45.176 with ) by smtp6005.mail.ssk.ynwp.yahoo.co.jp with SMTP; 12 Jun 2022 06:43:17 -0000 X-YMail-JAS: EPn7kHMVM1mDyBS.0j8o6KCwWU_7gDh_3yB.T6Osj6iQei8BlK6IIplTmkxJoIF8NtypRFeaNwwkApIxIHX5BKU6zcBMTPNV.gTmsVHQ13_KIHxgJr9i1.zIeVmqVz02nXLEj1jxHA-- X-Apparently-From: X-YMail-OSG: FcgEl9AVM1mSbR0CNZCi2V2WsDBgIutaBzGKpxHOnSIhwnN mqFIdi8M0C6ciRJJdhwUfRB90u.ybJXCyma6tQqMPXBz3Uw0p538CWEDIqNL wifOJXa6pC5jrZM.iotLfI14ZwDhSGwGPw8e_.bOwDrOKsSLZGzv2KJeZHVc ZDOYcUSfxIr7bP9qHpVUQC05P24aquKFVjjjqvZlEZ81JfEd10MDARyI40yi tJXe_Q_hA7BR9RmUnC7Dx0mUHK0ZkszmsaS.YU_k6ghheN4hqK7OsXKKLA14 75hNnmkyeRfKMm3jfzz6y5fCkjA9ROA2kpwNh6rkl_PxA8OOyVOnpwvYg87t gNZT_7toy1VesPwsYM.9PDSaMdf04Dka1qHuGWm_WzmluoCnAVK5sGymEVmD kzCUF8t52Hd.sgFlCsBPawii8enJ02WkE_ZQVrbgfaBEDZOtx8YXQwPdusdn WiHY.GvP7yqwmpBjQIL6KMddSqGGMuuQ77RQNhaVZy1_RJgt5z_a89bwOEBa upa17LXDp2AFTFKWu7N.Hj3kYrLHZOs8uW1KtbePoX.wEO6na5Ix1xD3sUaV VUOhfcyWFio.IXxrFmXH8S1nnPKQ649cimu2MMmAXxXDpP2U7lFbixgD6Jam dVhnKVUVpi.i5IEQxe6pQvM5DoAd2HNFQ5W_IQhrTn66H.dzzbHawr8YIciD fHHvxDveAX1wLXARnP27gROwUDE_1SaxHlrg75.fOBUppJwiIUbV9sachqCy 8RWIGeoX4ETdVIy29EgSNzc9QIhXVQK_15xjCdyZszW9xyzSspAZQjOfxQpv goKSLOX_TdVh2rappgSO51xLyeYO4sbuyTWJH8w0exJ7jXd6lzZggVeeNUuf CMbtyZPr3qDMDbepVeEVRjB7CaJRwzjhkP7k_sec83Dv46guO5NsjQtZUgCz vHYg1g3eGCGdHSiPYhg-- Message-ID: Date: Sun, 12 Jun 2022 15:38:23 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Content-Language: en-US To: GCC Patches Subject: [PATCH 3/4] xtensa: Make use of BALL/BNALL instructions X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, 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 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: Takayuki 'January June' Suwa via Gcc-patches From: Takayuki 'January June' Suwa Reply-To: Takayuki 'January June' Suwa Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" In Xtensa ISA, there is no single machine instruction that calculates unary bitwise negation, but a few similar fused instructions are exist: "BALL Ax, Ay, label" // if ((~Ax & Ay) == 0) goto label; "BNALL Ax, Ay, label" // if ((~Ax & Ay) != 0) goto label; These instructions have never been emitted before, but it seems no reason not to make use of them. gcc/ChangeLog: * config/xtensa/xtensa.md (*masktrue_bitcmpl): New insn pattern. gcc/testsuite/ChangeLog: * gcc.target/xtensa/BALL-BNALL.c: New. --- gcc/config/xtensa/xtensa.md | 21 +++++++++++++ gcc/testsuite/gcc.target/xtensa/BALL-BNALL.c | 33 ++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 gcc/testsuite/gcc.target/xtensa/BALL-BNALL.c diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index 25b8d2fb3c9..090a2939684 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -1627,6 +1627,27 @@ (set_attr "mode" "none") (set_attr "length" "3")]) +(define_insn "*masktrue_bitcmpl" + [(set (pc) + (if_then_else (match_operator 3 "boolean_operator" + [(and:SI (not:SI (match_operand:SI 0 "register_operand" "r")) + (match_operand:SI 1 "register_operand" "r")) + (const_int 0)]) + (label_ref (match_operand 2 "" "")) + (pc)))] + "" +{ + switch (GET_CODE (operands[3])) + { + case EQ: return "ball\t%0, %1, %2"; + case NE: return "bnall\t%0, %1, %2"; + default: gcc_unreachable (); + } +} + [(set_attr "type" "jump") + (set_attr "mode" "none") + (set_attr "length" "3")]) + ;; Zero-overhead looping support. diff --git a/gcc/testsuite/gcc.target/xtensa/BALL-BNALL.c b/gcc/testsuite/gcc.target/xtensa/BALL-BNALL.c new file mode 100644 index 00000000000..ba61c6f371b --- /dev/null +++ b/gcc/testsuite/gcc.target/xtensa/BALL-BNALL.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +extern void foo(void); + +void BNONE_test(int a, int b) +{ + if (a & b) + foo(); +} + +void BANY_test(int a, int b) +{ + if (!(a & b)) + foo(); +} + +void BALL_test(int a, int b) +{ + if (~a & b) + foo(); +} + +void BNALL_test(int a, int b) +{ + if (!(~a & b)) + foo(); +} + +/* { dg-final { scan-assembler-times "bnone" 1 } } */ +/* { dg-final { scan-assembler-times "bany" 1 } } */ +/* { dg-final { scan-assembler-times "ball" 1 } } */ +/* { dg-final { scan-assembler-times "bnall" 1 } } */