From patchwork Sun May 29 10:44:32 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: 54484 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 CD9ED38387F6 for ; Sun, 29 May 2022 11:00:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CD9ED38387F6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1653822037; bh=M8cHM38G8Hq/5m2/kFLn+vGshttMBOtlYXQkR73IHFo=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=wTMP/6t7ydqNqkoya/Wnq/zEvGgkHwIPHVyiQ2E+tosjotdbPJDq5mRfP5Ty4+aMl 1MJLLRX5jGBjuZvDkibttVN4hoziEcIQ2pHyRL0WQkkB02cMmNoi75jyO5rK9Q2dsz E+BFkUfAYNfnFYrlij6Bw6Pw6EqP2IZU+xHq/aWI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nh505-vm12.bullet.mail.kks.yahoo.co.jp (nh505-vm12.bullet.mail.kks.yahoo.co.jp [183.79.57.114]) by sourceware.org (Postfix) with SMTP id B67663856DC3 for ; Sun, 29 May 2022 11:00:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B67663856DC3 Received: from [183.79.100.141] by nh505.bullet.mail.kks.yahoo.co.jp with NNFMP; 29 May 2022 11:00:03 -0000 Received: from [183.79.100.137] by t504.bullet.mail.kks.yahoo.co.jp with NNFMP; 29 May 2022 11:00:03 -0000 Received: from [127.0.0.1] by omp506.mail.kks.yahoo.co.jp with NNFMP; 29 May 2022 11:00:03 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 731888.81333.bm@omp506.mail.kks.yahoo.co.jp Received: (qmail 50971 invoked by alias); 29 May 2022 11:00:03 -0000 Received: from unknown (HELO ?192.168.2.3?) (175.177.45.170 with ) by smtp5006.mail.kks.ynwp.yahoo.co.jp with SMTP; 29 May 2022 11:00:03 -0000 X-YMail-JAS: zCAV3wgVM1kByFvgSrFJ8OT_s3Q1qtzV1P1jjWImVeMPM.JvAvmvJMofdaa8oehmECmGjTBYO8cXJrfocxX2fc2L_.Ubv9vPoiwSlOctnz1gg6rqWeVBBPv29AM0M3Xnk2FQLICIBA-- X-Apparently-From: X-YMail-OSG: YpP6OXwVM1lhPEvbeWzTbjTWGYpQMhbjWNWtiatS.1bq09h a6HPlBTrIldMz4oJdg8L3EFogFikY_FijAkfeqIl1Y3C_WXP5YhI7WRNaOkZ L3NzYpmQupyYmvk3lzyds_Mj5YO8GN9Zt73oElIGU66aMAl2x3q0Y9ZCVKWr UOtk1hTimVakC9qHLmexi.ATQnSBZrHvET5CEKwu1GJOjfjnzCAzzn8bM78u Z2KEfipx7CgLUEeO_nImiTekaMxJwF9CIGYzq7se8z7K6pHjFgQ4eNnUXuUY 380B.vCfNVC_a_V2Hr5jnN3_PSu_MSkyIv3AXLlT_jYid3OC3gjeyNw3TYJ7 Bwn7KAycUqfiaWFC4ADoBy7gRq0rHDSYxWD53HfXhqkg4NOoQdyFgZOhtBqz _9WSXa4JrrDQ3Np.FY2Bezfki8fseilQ2BCoj8YLGaJ7nfRTNiVMrTBzo7MQ ZpO8MZhgWLD0Yve6jGg1H98ZbmJrhFRl0_ow3Rcmih5eY0QInd_dgu8_3KQB tuQz3lLttsBl.CQGZwL08kwAFw9GZD2kTu4s8Bw6szrvp2OyJpYLCj6Bu_KA hhXzgvhAT9Z84Jji93Hy_rt_bust75wJgRQLoz_G_nANHvVJ3tfm.ox6NCiP SJ1c48hnkCvKGsfg2kXlUT6y79UJGUFy8SoRnX8VSnz9Vs5_SOh1.ZtZSVA7 2E8bVWdmPLF0pCIQ108cvnfwklE.BIvjrGmcyKJNFu3Zwpl_gi01KiKMfavL WvSIQ03ek16g1lzd4XkBzq8gddABg.O76BTtvQPXbueuGMU9bg67i49858Y_ uwsO_wJjW1wHL4vIBa.J7GzRFDAVS.XzzWWV6QAbLlthe9aOCnvXgtSLVcRb CHg1UNHvmLLpQdVY3GyAZerGQL.j6wI0MOQWrJuEKwtTnUjzcRoScmQeQSCO MsorGoVT60BuTTd1y Message-ID: <35ee614e-9ab5-0bba-bcc2-6e27c9ef3d6a@yahoo.co.jp> Date: Sun, 29 May 2022 19:44:32 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Content-Language: en-US To: GCC Patches Subject: [PATCH 1/4] xtensa: Implement bswaphi2 insn pattern X-Spam-Status: No, score=-12.5 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, RCVD_IN_DNSWL_NONE, 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" This patch adds bswaphi2 insn pattern that is one instruction less than the default expansion. gcc/ChangeLog: * config/xtensa/xtensa.md (bswaphi2): New insn pattern. --- gcc/config/xtensa/xtensa.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index 6f5cbc541d8..217879bde15 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -471,6 +471,16 @@ ;; Byte swap. +(define_insn "bswaphi2" + [(set (match_operand:HI 0 "register_operand" "=a") + (bswap:HI (match_operand:HI 1 "register_operand" "r"))) + (clobber (match_scratch:HI 2 "=&a"))] + "" + "extui\t%2, %1, 8, 8\;slli\t%0, %1, 8\;or\t%0, %0, %2" + [(set_attr "type" "arith") + (set_attr "mode" "HI") + (set_attr "length" "9")]) + (define_expand "bswapsi2" [(set (match_operand:SI 0 "register_operand" "") (bswap:SI (match_operand:SI 1 "register_operand" "")))] From patchwork Sun May 29 10:46:16 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: 54486 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 0DE173838221 for ; Sun, 29 May 2022 11:02:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0DE173838221 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1653822151; bh=xwpmSrOs4irzb+6jAOYjdrpQ/a0AB2PCDw801dYPsrY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=muR+PVLeMYFpURH+xEF/Y9zT8wa0G0lw1/hUsur0qGAXE3VX/icf6juH3LGbShpk/ 1vD1HQWtGSTg1qc0h8PzsFTAo4rgLFJXW0RgDro7bdD9X5R3y+Iiw3nyLPijl29iPI EQPIdPCPdW8RMCUpQ4ZG3u1u70ffTOM9HhPAwYdY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nh602-vm9.bullet.mail.ssk.yahoo.co.jp (nh602-vm9.bullet.mail.ssk.yahoo.co.jp [182.22.90.34]) by sourceware.org (Postfix) with SMTP id E38003856264 for ; Sun, 29 May 2022 11:00:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E38003856264 Received: from [182.22.66.103] by nh602.bullet.mail.ssk.yahoo.co.jp with NNFMP; 29 May 2022 11:00:05 -0000 Received: from [182.22.91.128] by t601.bullet.mail.ssk.yahoo.co.jp with NNFMP; 29 May 2022 11:00:05 -0000 Received: from [127.0.0.1] by omp601.mail.ssk.yahoo.co.jp with NNFMP; 29 May 2022 11:00:05 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 191239.85783.bm@omp601.mail.ssk.yahoo.co.jp Received: (qmail 74216 invoked by alias); 29 May 2022 11:00:05 -0000 Received: from unknown (HELO ?192.168.2.3?) (175.177.45.170 with ) by smtp5001.mail.kks.ynwp.yahoo.co.jp with SMTP; 29 May 2022 11:00:04 -0000 X-YMail-JAS: ncvXB38VM1mXteI.8T.pshK6AKOH7haNZYShuANc0OO4YncUBXwJpnuB3Sr9IZH9kpEbn7eIyMKITYLEKFPWKirLLt.GkefhOcT0TnpNbMi_QzyZKs9PziGQQzJI.1A3Pm3opUu3Bw-- X-Apparently-From: X-YMail-OSG: mFfjS10VM1ngnBTI0HOAzQ04.aNKsUmZej5XxKMMczwpPi3 KYZor6_lJqakjAePzejVRJsnRmDsCUEb2XB5b6RptP2VNwI0v4rh8sV5hmGt 0maKGDTR1OWbVQvoYaPlZCyhHguC0n9EIlax.T6LVDQngKphZdOmMG0c2X6p BzPfDGIBAwOwDJxuY5mboosEctXjkMV7H8wIW.KWIi9VOYjYdY.VqsZzi_Ce ooAKtwTLKmthmdbRLLRspUjOWRi2SCfpiV1CbST_.iWHeW6ZFi1L2DICGNZB BV90wCwKliWIxNUFBJWKATedDUxqxz8HzWJISoe4Wz_4IU2kOESk7hU05Vq1 AC1HEyC0i.ilC6FygiBeSMHXJ1KQvzAPvGHnwDp2p_YgKVhkKuGSGqyh5jpc EXnx5hE_9wPvL0DKknHJxSs8wLay2LylMrbSm8_ed49OP.3CL0LXueoyHX_4 Om0TlWBUozObvXUT_g2n_Jgj5OELMz6zKNwxdqRXX1UHIotN6yfqaFAutLiP FtbjEPt9odo9GeWVudvtVylAHbbxgK6IknnYpZSh2luwAJq4C12YJDeLkbX7 Wwcgx__in2KRh9KEI_cHs5zjlTcUExmZFJpJAM1.ItcnWUquWTIrX.n8K3wH fW0B7YhMGn7T7ki4xctS2AwxN3m1ugaCn15N_hi2QKZQmlrkcWkaastYqDFQ a1MPzRRyTjuUYuEtwt5bgE4qpjPprc3W4S1ZAxLlrbK_4OothIL67gfJK0fr cYQIDtAjloywwQcmq7pt6vwWTYIcZHGfTd8f3hluD4W4JKujsvp.sEZNM_PO a6tfAGlyET.Q9MxSqG.k9L_ORVfaS6Q.RHhnI7A9zF7QGyE10MeG9a20Y3j2 SnfbRh4wNLu1ZsoewaR3UD5_rCOZsbSJfEUhSmWkpD4nxiVx3ZKMg9D39IF5 .SET8OFR_u__VToHsNA-- Message-ID: <9835da53-f201-fe51-c9a5-dcf9d7297941@yahoo.co.jp> Date: Sun, 29 May 2022 19:46:16 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Content-Language: en-US To: GCC Patches Subject: [PATCH 2/4] xtensa: Make one_cmplsi2 optimizer-friendly X-Spam-Status: No, score=-12.6 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, RCVD_IN_DNSWL_NONE, 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 optimizers assume that bitwise negation can be done by a single insn. As a result, '((x < 0) ? ~x : x)' cannot be optimized to '(x ^ (x >> 31))' ever before, for example. This patch relaxes such limitation, by putting the insn expansion off till the split pass. gcc/ChangeLog: * config/xtensa/xtensa.md (one_cmplsi2): Rearrange as an insn_and_split pattern. gcc/testsuite/ChangeLog: * gcc.target/xtensa/one_cmpl_abs.c: New. --- gcc/config/xtensa/xtensa.md | 26 +++++++++++++------ .../gcc.target/xtensa/one_cmpl_abs.c | 9 +++++++ 2 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/gcc.target/xtensa/one_cmpl_abs.c diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index 217879bde15..f11ae4910f8 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -556,16 +556,26 @@ (set_attr "mode" "SI") (set_attr "length" "3")]) -(define_expand "one_cmplsi2" - [(set (match_operand:SI 0 "register_operand" "") - (not:SI (match_operand:SI 1 "register_operand" "")))] +(define_insn_and_split "one_cmplsi2" + [(set (match_operand:SI 0 "register_operand" "=a") + (not:SI (match_operand:SI 1 "register_operand" "r")))] "" + "#" + "&& can_create_pseudo_p ()" + [(set (match_dup 2) + (const_int -1)) + (set (match_dup 0) + (xor:SI (match_dup 1) + (match_dup 2)))] { - rtx temp = gen_reg_rtx (SImode); - emit_insn (gen_movsi (temp, constm1_rtx)); - emit_insn (gen_xorsi3 (operands[0], temp, operands[1])); - DONE; -}) + operands[2] = gen_reg_rtx (SImode); +} + [(set_attr "type" "arith") + (set_attr "mode" "SI") + (set (attr "length") + (if_then_else (match_test "TARGET_DENSITY") + (const_int 5) + (const_int 6)))]) (define_insn "negsf2" [(set (match_operand:SF 0 "register_operand" "=f") diff --git a/gcc/testsuite/gcc.target/xtensa/one_cmpl_abs.c b/gcc/testsuite/gcc.target/xtensa/one_cmpl_abs.c new file mode 100644 index 00000000000..608f65fd777 --- /dev/null +++ b/gcc/testsuite/gcc.target/xtensa/one_cmpl_abs.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +int one_cmpl_abs(int a) +{ + return a < 0 ? ~a : a; +} + +/* { dg-final { scan-assembler-not "bgez" } } */ From patchwork Sun May 29 10:55:44 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: 54485 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 294DF38387F9 for ; Sun, 29 May 2022 11:01:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 294DF38387F9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1653822094; bh=lk6BPzmE8yEE+ACRMtvxVaG3tUxphPslMe1mk0/Ja1U=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=c2WBXc5ifAUDcboMxUkfSEdmdPf7NWMdua5ElPiUU0l7sa3L8HZ5djv1Fkrgq5VRI 7E4as5cxFQNeMI3TbTcFFvv3EoCd8X/Y9FWKqnZnoXEA49/3nwJjjmJpeDc0VITgas PkeSXvwPcrCyCSVblyrijPJ0cCw5PjmNyJzNJneE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nh505-vm0.bullet.mail.kks.yahoo.co.jp (nh505-vm0.bullet.mail.kks.yahoo.co.jp [183.79.57.102]) by sourceware.org (Postfix) with SMTP id 0617C385DC05 for ; Sun, 29 May 2022 11:00:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0617C385DC05 Received: from [183.79.100.139] by nh505.bullet.mail.kks.yahoo.co.jp with NNFMP; 29 May 2022 11:00:06 -0000 Received: from [183.79.100.133] by t502.bullet.mail.kks.yahoo.co.jp with NNFMP; 29 May 2022 11:00:06 -0000 Received: from [127.0.0.1] by omp502.mail.kks.yahoo.co.jp with NNFMP; 29 May 2022 11:00:06 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 214533.14149.bm@omp502.mail.kks.yahoo.co.jp Received: (qmail 55032 invoked by alias); 29 May 2022 11:00:06 -0000 Received: from unknown (HELO ?192.168.2.3?) (175.177.45.170 with ) by smtp5002.mail.kks.ynwp.yahoo.co.jp with SMTP; 29 May 2022 11:00:06 -0000 X-YMail-JAS: T0kpttIVM1lMtqDIeXCJfHVL5qrnYw_lqgnrWSgr_jyOjd0NGVNMnpmZIJDe9PO2pIScWBNGSp.jvUBsie3QthY8wrGnNmGkUR5jSjJh5siQ5_La0JY4k3FjMEAvXBDONv3W0cirkA-- X-Apparently-From: X-YMail-OSG: 4SN5nnsVM1las2YAX7HOxpe841xcTF9kghfgJlF9.TvmVEz 6b7vyRT1sU_s0orDCtNdyA4jUpISW8jPvH9aKTZBoMja0YrAmcNXV6tlsuDX dLbGVWxzo8oaDbIYj4eD4HyjOWIKHYzWGM_MYv.AWDV3RNfdTDNJfyXWu9do oOOm6IEFDQuCPOxrBQqBOeJeHQPjPYzcg4RXH6U2nFD1PQvM0z1eBqmSjen7 hDL1PX4o0DcNQx_aXjDNQlpM8SCduE2WGXmPCR9gOOAipp3bG6vzhrNm37Xa tttKZA_q4Yc31gAgL9L8KYtxQJdwbvF71RJHrOam2fFz_luAOButZC6i9dFW 7VxOELEmVN59rf4tXZ0UhrG5yQg0qYagZH5RnyzV7UprRV346elyfTVterR5 vt4MtknLm2.Y9xwTCddgYK5qAFhuADBuJLqWEgMJfTikxPixnjTZy.FiEFWj _YaU4_tqnB5qVfhDpSzdB34uFWBGFgWlp72XvE_O81J.g92WKrb1g76Fd_jy GiLwGMHlf839GVhbEX1DCibqgmRQRAJJVg_YQpTIWyMET_UnoXJdGZ8LodtE YjsPaChaPeZM_NtWiHGCitsTF1Yhnt.bnIrymFbzryWu.tQNyE0K3VRHGgxj PwYDRuIt_Jqd9ZlfTtgeACPvljOZnc23P0f1FxblZIW_Lr7usg5dNlwarara oN9vVlAaFx2hmrR8a8a55LBbr7Rb9f38Bffk4Sm34W5S3qbM6iSuCtKYfjpC XqvBE_O8G6sVVYCYyqhzKxLkvbsNLYHSgtK3SYI3sP7WZ9czrbMPBIwFC77H QTZahw_2hpbaC.kcbrO6rpDrhgealw2lWwToGPqemu9hLPXqXTE6IIgqi9cL szvsDfI1CE.Jo8QuTJO1njeON2mde2z9UzqfrQTTtsQ79W_e6P9z_g3mr015 mUF3qfxVpxO9Anx9cOA-- Message-ID: <123a21c0-f79a-70a4-9ee6-abf874e3a695@yahoo.co.jp> Date: Sun, 29 May 2022 19:55:44 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Content-Language: en-US To: GCC Patches Subject: [PATCH 3/4] xtensa: Optimize '(~x & y)' to '((x & y) ^ y)' 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, RCVD_IN_DNSWL_NONE, 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. gcc/ChangeLog: * config/xtensa/xtensa.md (*andsi3_bitcmpl): New insn_and_split pattern. gcc/testsuite/ChangeLog: * gcc.target/xtensa/check_zero_byte.c: New. --- gcc/config/xtensa/xtensa.md | 20 +++++++++++++++++++ .../gcc.target/xtensa/check_zero_byte.c | 9 +++++++++ 2 files changed, 29 insertions(+) create mode 100644 gcc/testsuite/gcc.target/xtensa/check_zero_byte.c diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index f11ae4910f8..4aa128eab64 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -601,6 +601,26 @@ (set_attr "mode" "SI") (set_attr "length" "3,3")]) +(define_insn_and_split "*andsi3_bitcmpl" + [(set (match_operand:SI 0 "register_operand" "=a") + (and:SI (not:SI (match_operand:SI 1 "register_operand" "r")) + (match_operand:SI 2 "register_operand" "r")))] + "" + "#" + "&& can_create_pseudo_p ()" + [(set (match_dup 3) + (and:SI (match_dup 1) + (match_dup 2))) + (set (match_dup 0) + (xor:SI (match_dup 3) + (match_dup 2)))] +{ + operands[3] = gen_reg_rtx (SImode); +} + [(set_attr "type" "arith") + (set_attr "mode" "SI") + (set_attr "length" "6")]) + (define_insn "iorsi3" [(set (match_operand:SI 0 "register_operand" "=a") (ior:SI (match_operand:SI 1 "register_operand" "%r") diff --git a/gcc/testsuite/gcc.target/xtensa/check_zero_byte.c b/gcc/testsuite/gcc.target/xtensa/check_zero_byte.c new file mode 100644 index 00000000000..6a04aaeefa0 --- /dev/null +++ b/gcc/testsuite/gcc.target/xtensa/check_zero_byte.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +int check_zero_byte(int v) +{ + return (v - 0x01010101) & ~v & 0x80808080; +} + +/* { dg-final { scan-assembler-not "movi" } } */ From patchwork Sun May 29 10:57:35 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: 54487 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 7EF2738387FC for ; Sun, 29 May 2022 11:03:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7EF2738387FC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1653822214; bh=lX3zYmpBshiNA/KunKRe3ri/hQwGv2bnntPTfvL9N9g=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=iFyLY5UIYhnRdtM1ncIB1e7rp6YvGizEGciEjq9SfzEsIvwxZfVZZi9w4/gU/p+u7 PFeFM8AL2GjasDov+imrpbcBmWPAEwLqo7BZoel8MMV/BX95frRUkJ3WIkzilFexqS /UoSUONYEABWWoinevr7zB7qvs/D73CYir1CiYWo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nh601-vm12.bullet.mail.ssk.yahoo.co.jp (nh601-vm12.bullet.mail.ssk.yahoo.co.jp [182.22.90.21]) by sourceware.org (Postfix) with SMTP id 887EB385E833 for ; Sun, 29 May 2022 11:00:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 887EB385E833 Received: from [182.22.66.104] by nh601.bullet.mail.ssk.yahoo.co.jp with NNFMP; 29 May 2022 11:00:07 -0000 Received: from [182.22.91.131] by t602.bullet.mail.ssk.yahoo.co.jp with NNFMP; 29 May 2022 11:00:07 -0000 Received: from [127.0.0.1] by omp604.mail.ssk.yahoo.co.jp with NNFMP; 29 May 2022 11:00:07 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 680856.30293.bm@omp604.mail.ssk.yahoo.co.jp Received: (qmail 55039 invoked by alias); 29 May 2022 11:00:07 -0000 Received: from unknown (HELO ?192.168.2.3?) (175.177.45.170 with ) by smtp5002.mail.kks.ynwp.yahoo.co.jp with SMTP; 29 May 2022 11:00:07 -0000 X-YMail-JAS: 6sF_ioEVM1nDP1aitFu9ih2XuqjM95dxgjq.Nl7JyyWuMC8G2Guju1cboobfQH8nxfbxxl.t42pzxG8vce9Tsbb42HEtwwoTWqhDjOIaQEyAVGs7QGWkuLB8CSQT4s6CE0RBHv_pJw-- X-Apparently-From: X-YMail-OSG: o5mw7EwVM1n8dxv8QxJwpImOUADjLMus1hAFQEfuWbj1OxZ UdvitgSRz9jUJeud_xQTok3dnwcb9tyZ2UvuIQOYZyOuE2AyRSRi7TmT06wg gkXQBsOpemWrPkxdyuUhayBEkcBBEPCAri4x1Ha8CGP3o_X4IXwgjMEUT9tM TdK0tTQ0RhzfydQdieVfMwGNPQ_bEk7P0c8kCO4s29dsGcQv1GnGCgGMSWrj LyojsN3Gs5nKLNShmkGqIYb0TwaNbwvozOTiZEV85pQuTOIw5hdPLP8NeR2b w8QkM2BX1WaqrrBgfu9sYzik9wk5yXe5x72UUlP58Nyk_pxpXwv6V0deFXxN vmZDM4seAzjJomViBDGG0OORQaHsy0v.RfSBBQcA6ieHhzACwWR_HPX7H3vs SW5UX78sq5IPIukmoKS.8bPbMfA.Qi6p6SigWRfSaNDzDKZOY2_sQ8kR2_Nr qWse76k0nlHzb9PKizFcVRcOPzoyEXNcmiPng0MqzR3mW03h9Hphnf.V402. Ej5JOSQCu.4OlU7cqQRVIuNNOvUZDwU7jzC2PI5C8F8IADWTC1gAlaVHOcyq eghK0uT.BIYiVY5CqY9JqJKL58UGu_Ogzg6ZZEBRcKdXyYebQHv9oci5ZCwW fGYjYjQAUUfw3F_MnRwnZ_xdnhZXUwv_r8cxqWUXR2afc0oyoSPW2RGY6NG2 mI8pD0XKJtU4J_kwl_LYxIRVOkk4OjMpSFukb8N3yHFXyh5Nws7xJWd.BFzz 1_YO1qHdV4XDvwp2e3UuPYCzrdCzLAmShABdFsBSqO8dAt5hnoTDNjHeiEE3 qDFYrQWlpAWgo2Bn782gfD2nXlboYxR7gLBhTR14Ws1m.xFCBHbhGIEAzOm4 nBAa0z3rnDIgwI4KzJmJc4omIBuaV6GptEGZjByaNnJeCKwn_mkfblNEFIor J2KhvREOWmVJWxeqJFA-- Message-ID: <0d69cc30-47f6-0bbd-c482-5a5c60a37252@yahoo.co.jp> Date: Sun, 29 May 2022 19:57:35 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Content-Language: en-US To: GCC Patches Subject: [PATCH 4/4] xtensa: Add clrsbsi2 insn pattern 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, RCVD_IN_DNSWL_NONE, 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" > (clrsb:m x) > Represents the number of redundant leading sign bits in x, represented > as an integer of mode m, starting at the most significant bit position. This explanation is just what the NSA instruction (not ever emitted before) calculates in Xtensa ISA. gcc/ChangeLog: * config/xtensa/xtensa.md (clrsbsi2): New insn pattern. libgcc/ChangeLog: * config/xtensa/lib1funcs.S (__clrsbsi2): New function. * config/xtensa/t-xtensa (LIB1ASMFUNCS): Add _clrsbsi2. --- gcc/config/xtensa/xtensa.md | 12 +++++++++++- libgcc/config/xtensa/lib1funcs.S | 23 +++++++++++++++++++++++ libgcc/config/xtensa/t-xtensa | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index 4aa128eab64..dec49cc942b 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -429,7 +429,17 @@ (set_attr "length" "3")]) -;; Count leading/trailing zeros and find first bit. +;; Count redundant leading sign bits and leading/trailing zeros, +;; and find first bit. + +(define_insn "clrsbsi2" + [(set (match_operand:SI 0 "register_operand" "=a") + (clrsb:SI (match_operand:SI 1 "register_operand" "r")))] + "TARGET_NSA" + "nsa\t%0, %1" + [(set_attr "type" "arith") + (set_attr "mode" "SI") + (set_attr "length" "3")]) (define_insn "clzsi2" [(set (match_operand:SI 0 "register_operand" "=a") diff --git a/libgcc/config/xtensa/lib1funcs.S b/libgcc/config/xtensa/lib1funcs.S index 5a2bd20534f..3932d206256 100644 --- a/libgcc/config/xtensa/lib1funcs.S +++ b/libgcc/config/xtensa/lib1funcs.S @@ -456,6 +456,29 @@ __nsau_data: #endif /* L_clz */ +#ifdef L_clrsbsi2 + .align 4 + .global __clrsbsi2 + .type __clrsbsi2, @function +__clrsbsi2: + leaf_entry sp, 16 +#if XCHAL_HAVE_NSA + nsa a2, a2 +#else + srai a3, a2, 31 + xor a3, a3, a2 + movi a2, 31 + beqz a3, .Lreturn + do_nsau a2, a3, a4, a5 + addi a2, a2, -1 +.Lreturn: +#endif + leaf_return + .size __clrsbsi2, . - __clrsbsi2 + +#endif /* L_clrsbsi2 */ + + #ifdef L_clzsi2 .align 4 .global __clzsi2 diff --git a/libgcc/config/xtensa/t-xtensa b/libgcc/config/xtensa/t-xtensa index 9836c96aefc..084618b382e 100644 --- a/libgcc/config/xtensa/t-xtensa +++ b/libgcc/config/xtensa/t-xtensa @@ -1,6 +1,6 @@ LIB1ASMSRC = xtensa/lib1funcs.S LIB1ASMFUNCS = _mulsi3 _divsi3 _modsi3 _udivsi3 _umodsi3 \ - _umulsidi3 _clz _clzsi2 _ctzsi2 _ffssi2 \ + _umulsidi3 _clz _clrsbsi2 _clzsi2 _ctzsi2 _ffssi2 \ _ashldi3 _ashrdi3 _lshrdi3 \ _bswapsi2 _bswapdi2 \ _negsf2 _addsubsf3 _mulsf3 _divsf3 _cmpsf2 _fixsfsi _fixsfdi \