From patchwork Fri Jun 10 04:17:40 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: 54999 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 750E2383EC7C for ; Fri, 10 Jun 2022 04:26:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 750E2383EC7C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1654835213; bh=ZOK5zttpoPTwaisRQDh8UG3m0Bl++wy1Pa670thkbNY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ZhJSvC2go4ZL2b1xq8dqgdIqIFeDAb3RmgDCjZH5z0rTuPivUwsMlAtuwttIPFayj EeoNFgKO50iIYa5c983mGXAdWbsgvwLJCxLlYs1gYLgb4a+EECBszLHBq1QT2KuLZ7 YP5ScWJ9EL3SjzqQvd02xLmPxLsxt5GfS4JMww68= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nh503-vm2.bullet.mail.kks.yahoo.co.jp (nh503-vm2.bullet.mail.kks.yahoo.co.jp [183.79.56.188]) by sourceware.org (Postfix) with SMTP id 7EB6B384D162 for ; Fri, 10 Jun 2022 04:26:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7EB6B384D162 Received: from [183.79.100.138] by nh503.bullet.mail.kks.yahoo.co.jp with NNFMP; 10 Jun 2022 04:26:04 -0000 Received: from [183.79.100.134] by t501.bullet.mail.kks.yahoo.co.jp with NNFMP; 10 Jun 2022 04:26:04 -0000 Received: from [127.0.0.1] by omp503.mail.kks.yahoo.co.jp with NNFMP; 10 Jun 2022 04:26:04 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 928977.91574.bm@omp503.mail.kks.yahoo.co.jp Received: (qmail 5271 invoked by alias); 10 Jun 2022 04:26:04 -0000 Received: from unknown (HELO ?192.168.2.3?) (175.177.45.164 with ) by smtp6004.mail.ssk.ynwp.yahoo.co.jp with SMTP; 10 Jun 2022 04:26:04 -0000 X-YMail-JAS: NC2g6AcVM1mQr0m41Q0T1I6pFKcaT5IVyhupGm2CH8LV8TR25swC_zcdFh9fuEjoktgmJCOV1zU9Y7Ppj7GfqgjmMUsUYpLnP7DiqmXnTqb5Y2f__r.kb2sx.OiMyVpOZ5TscUDhUQ-- X-Apparently-From: X-YMail-OSG: 2o4nIFQVM1nwzO9U04cd2eOahZ2YjdoB6Nlh4gl_pF1t_KM WelZZ0EzNnTmZva8SgSyekd2fnT.ErSWXGJ029sMlgitusjKQTUGD9I7tt5J CHOYUVF6sXmsreQ7iTmSzLyN8ix8kSsLcgXur7JgM1GI6mlXxCZh1KZFKLhZ 4AfreryXTqnO5RXhvngcun4Phu0aTnZBDnI5kWdDeAlxOgeSnqrPmWAqH1zu gebqOoHW7WKyzZ0U7b7NtG3V82QV2PCGRRMl_4Id4Llk2aGLPR2oCa.eXaTA CGwi6aB7FLHN978b8ICSAofXhHGzedfih2HHnp_Hc5FT3vwFB9VKfMS6WuEF tT_YUVYlcxumTCrOvR0AjB.109_Qu62mJiJyDx0tgwqaVuBUJktyghHaXdWT jxf.TaixR58a_d46ggCpDpcYRjwnX1Il28q5NsiM6MsNOu4HLMDU7zTjJblr H2N3nOzDWivyhiaLwGddh9W0d9dTtAwJw_eyHOhRNdnPgltcSrggo73zET6C qF5I39DIXRYBl9c7GJxYGSqzkZIOKWYrWksrGVXMCCiZgvyJJik8Cqd9IoH0 Vf1i4K6.l_BlUc_pPGKbV8id6fJp_HBU3L8q6vvo9Srsxku7jwYWn3YUSBw0 gVlV2jlRBE2EQxo7FCgRu5zE36MiiBu9BlVk0oL_OOrIVCKKKwPG44DHNMLk erT4V2N1aPqASXBXvH.hXe5VUUSQb4yuVmZ3iPU1zUVjUQijgGQKd8f5ttVM lcCjeQ_KTfKOgpXbYCEFN0PSPVEij_q._gExk1UWRi8iqtuwtyv8jm5SfVVw mEOKS5D.LEMq4.Kxg7l3Nsw3fs6AXJy.gJiZRt8h1JdDWorO1PGQul9yjD0i tdj5eMT8DdLuIL2NYvEtkhniiJM2P0z358_HYJPRy7cG.cXXamG_fINjz8.3 DlRJttCNyuldl80zy7g-- Message-ID: Date: Fri, 10 Jun 2022 13:17:40 +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 1/4] xtensa: Tweak some widen multiplications X-Spam-Status: No, score=-13.0 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" umulsidi3 is faster than umuldi3 even if library call, and is also prerequisite for fast constant division by multiplication. gcc/ChangeLog: * config/xtensa/xtensa.md (mulsidi3, umulsidi3): Split into individual signedness, in order to use libcall "__umulsidi3" but not the other. (mulhisi3): Merge into one by using code iterator. (mulsidi3, mulhisi3, umulhisi3): Remove. --- gcc/config/xtensa/xtensa.md | 56 +++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index 8ff6f9a95fe..33cbd546de3 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -224,20 +224,42 @@ ;; Multiplication. -(define_expand "mulsidi3" +(define_expand "mulsidi3" [(set (match_operand:DI 0 "register_operand") - (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand")) - (any_extend:DI (match_operand:SI 2 "register_operand"))))] + (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand")) + (sign_extend:DI (match_operand:SI 2 "register_operand"))))] "TARGET_MUL32_HIGH" { rtx temp = gen_reg_rtx (SImode); emit_insn (gen_mulsi3 (temp, operands[1], operands[2])); - emit_insn (gen_mulsi3_highpart (gen_highpart (SImode, operands[0]), - operands[1], operands[2])); + emit_insn (gen_mulsi3_highpart (gen_highpart (SImode, operands[0]), + operands[1], operands[2])); emit_insn (gen_movsi (gen_lowpart (SImode, operands[0]), temp)); DONE; }) +(define_expand "umulsidi3" + [(set (match_operand:DI 0 "register_operand") + (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand")) + (zero_extend:DI (match_operand:SI 2 "register_operand"))))] + "" +{ + if (TARGET_MUL32_HIGH) + { + rtx temp = gen_reg_rtx (SImode); + emit_insn (gen_mulsi3 (temp, operands[1], operands[2])); + emit_insn (gen_umulsi3_highpart (gen_highpart (SImode, operands[0]), + operands[1], operands[2])); + emit_insn (gen_movsi (gen_lowpart (SImode, operands[0]), temp)); + } + else + emit_library_call_value (gen_rtx_SYMBOL_REF (Pmode, "__umulsidi3"), + operands[0], LCT_NORMAL, DImode, + operands[1], SImode, + operands[2], SImode); + DONE; +}) + (define_insn "mulsi3_highpart" [(set (match_operand:SI 0 "register_operand" "=a") (truncate:SI @@ -261,30 +283,16 @@ (set_attr "mode" "SI") (set_attr "length" "3")]) -(define_insn "mulhisi3" - [(set (match_operand:SI 0 "register_operand" "=C,A") - (mult:SI (sign_extend:SI - (match_operand:HI 1 "register_operand" "%r,r")) - (sign_extend:SI - (match_operand:HI 2 "register_operand" "r,r"))))] - "TARGET_MUL16 || TARGET_MAC16" - "@ - mul16s\t%0, %1, %2 - mul.aa.ll\t%1, %2" - [(set_attr "type" "mul16,mac16") - (set_attr "mode" "SI") - (set_attr "length" "3,3")]) - -(define_insn "umulhisi3" +(define_insn "mulhisi3" [(set (match_operand:SI 0 "register_operand" "=C,A") - (mult:SI (zero_extend:SI + (mult:SI (any_extend:SI (match_operand:HI 1 "register_operand" "%r,r")) - (zero_extend:SI + (any_extend:SI (match_operand:HI 2 "register_operand" "r,r"))))] "TARGET_MUL16 || TARGET_MAC16" "@ - mul16u\t%0, %1, %2 - umul.aa.ll\t%1, %2" + mul16\t%0, %1, %2 + mul.aa.ll\t%1, %2" [(set_attr "type" "mul16,mac16") (set_attr "mode" "SI") (set_attr "length" "3,3")])