From patchwork Wed Jul 13 11:40:13 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: 56023 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 DEC38386CE40 for ; Wed, 13 Jul 2022 11:42:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DEC38386CE40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1657712522; bh=Gd/PpfVd1B91rlo6pZAI2VMph94WobJbbadp/4ZFmsQ=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=qS7Cfp7Z4dJnA7mJHMRhFvDCfJlzrcYzFnHnICohpCv5S5BxTs8r+uj+YVOB7a174 1o8m96p2G95TkzlznjYVDeOmNr+/2YVwcTpu4K6zpkPjKGqUSWoO6GmZ2Mtz1xJj/+ DSoAzpTGc+VZOhTXaHs/8dA2+J8qmio8kkyQsmvI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nh501-vm8.bullet.mail.kks.yahoo.co.jp (nh501-vm8.bullet.mail.kks.yahoo.co.jp [183.79.56.138]) by sourceware.org (Postfix) with SMTP id 566663857836 for ; Wed, 13 Jul 2022 11:41:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 566663857836 Received: from [183.79.100.140] by nh501.bullet.mail.kks.yahoo.co.jp with NNFMP; 13 Jul 2022 11:41:30 -0000 Received: from [183.79.101.123] by t503.bullet.mail.kks.yahoo.co.jp with NNFMP; 13 Jul 2022 11:41:30 -0000 Received: from [127.0.0.1] by omp510.mail.kks.yahoo.co.jp with NNFMP; 13 Jul 2022 11:41:30 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 825131.36726.bm@omp510.mail.kks.yahoo.co.jp Received: (qmail 81356 invoked by alias); 13 Jul 2022 11:41:30 -0000 Received: from unknown (HELO ?192.168.2.4?) (175.177.45.167 with ) by smtp5003.mail.kks.ynwp.yahoo.co.jp with SMTP; 13 Jul 2022 11:41:30 -0000 X-YMail-JAS: eso6LwEVM1kT9696OuQarEsAchBvq1ZhGEO6lvWSaip6Wp7bLEzSFZ0TGrkiJ3PHbia3YBCiGeYT4i4qhmC9Wxnbe9CQ72YdSL6AYof8sO_4aGJZyYZWiHLQdz7WjSO9NWNVVU_hFw-- X-Apparently-From: X-YMail-OSG: OdePZK8VM1kWQQBMN.rDqkAQ6_Ivw83i_JyrA3w0FNYapDQ .oZPNBjSXyD9p2SswEMKGqjn1oQ5pwdpeEKG297KwIxccTbv7WZWbUh4GTQG Qtf3WR_FYwnxMU0RxBa1cAm45HicUUiM5hAE0IwNg2o8K8KIBii6c5HuTnaW SdQHKm8mt6UYTIUX6ZJT8KHSEGbE2tv_gD0UX.D1gwYxlJJATO9hIklWyG9e uP6.1bcCtPZmZ9K1fgZSzW9LA.VXs8EpiIJiU.C2iAZGh7f4s9dhIrDE3hRZ EzsdKnad.YReFjvZF9zVnX9ZQVhjTRRY2BV45e2Nq6IZZGpi8zUMzkl4DgcC HIwAqhs0C3wFp_NzAl4Hqe19nQ6C4FKzNK9_vdMuTfUzO9oUVPC4yv.5YxUH hU5ORS3B2vZFztYQAc23ds2MRtZSCWNwyJlJssdzILymn.5DL47WzylQx1A4 kJCpEJwk_i7Nd9otoUHR_TghoI7jSwr4ApLPNpYAsmHStNQsUNPhUwB1Wctr YeP_yv915vT_HWOxcbngdY1VPSLUwHBf5gF6kTVWMXuFlVQ_R4hc8d0WTgAH f2MNyRkJONm2cJz2qV0fbU7clsNcuXMcChKIq3aSgmwJYGKedznz43dfqT.B 9wZQ2UY6KZSyso5Bm4g6wooD7s5uF.CkXfIa0hnGWqzQnkSYoYrwNGoXp3RK UNgEBouXgilS72IKFlbYCoWZW1FrcxQ6g.ylTvm4r3_WYgtMS2gg0IVIvoP3 1RSRMdnzbBfykaQPzqJmEF7fkzphOSZttbXJ2EQZRBRKRWqNlGjcQDEafnOB 0RI1Yu.TUT1NTI_OlGq81OOuv2c5Y3XACe28mk_kNyaltJsY_HCZ..0nf2uc 3QZwVt2_V8VhYMmljywxVwNgwLWilamy2TWWaUyUrSmci9lYXZPRHIrH9RHU t7jgRZxYkJC2Pi1resw-- Message-ID: <4341501e-8903-baf9-f831-3328bb86907d@yahoo.co.jp> Date: Wed, 13 Jul 2022 20:40:13 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.0.2 Content-Language: en-US To: GCC Patches Subject: [PATCH] xtensa: Minor fix for FP constant synthesis X-Spam-Status: No, score=-11.9 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, KAM_STOCKGEN, 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 fixes an non-fatal issue about negative constant values derived from FP constant synthesis on hosts whose 'long' is wider than 'int32_t'. And also replaces the dedicated code in FP constant synthesis split pattern with the appropriate existing function call. gcc/ChangeLog: * config/xtensa/xtensa.md: In FP constant synthesis split pattern, subcontract to avoid_constant_pool_reference() as in the case of integer, because it can handle well too. And cast to int32_t before calling xtensa_constantsynth() in order to ignore upper 32-bit. gcc/testsuite/ChangeLog: * gcc.target/xtensa/constsynth_double.c: Modify in order to catch the issue. --- gcc/config/xtensa/xtensa.md | 35 +++++-------------- .../gcc.target/xtensa/constsynth_double.c | 2 +- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index 9d998589631..6a58d3e2776 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -1244,35 +1244,16 @@ "! optimize_debug && reload_completed" [(const_int 0)] { - int i = 0; - rtx x = XEXP (operands[1], 0); - long l[2]; - if (SYMBOL_REF_P (x) - && CONSTANT_POOL_ADDRESS_P (x)) - x = get_pool_constant (x); - else if (GET_CODE (x) == CONST) - { - x = XEXP (x, 0); - gcc_assert (GET_CODE (x) == PLUS - && SYMBOL_REF_P (XEXP (x, 0)) - && CONSTANT_POOL_ADDRESS_P (XEXP (x, 0)) - && CONST_INT_P (XEXP (x, 1))); - i = INTVAL (XEXP (x, 1)); - gcc_assert (i == 0 || i == 4); - i /= 4; - x = get_pool_constant (XEXP (x, 0)); - } - else - gcc_unreachable (); - if (GET_MODE (x) == SFmode) - REAL_VALUE_TO_TARGET_SINGLE (*CONST_DOUBLE_REAL_VALUE (x), l[0]); - else if (GET_MODE (x) == DFmode) - REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (x), l); - else + rtx x = avoid_constant_pool_reference (operands[1]); + long l; + HOST_WIDE_INT value; + if (! CONST_DOUBLE_P (x) || GET_MODE (x) != SFmode) FAIL; + REAL_VALUE_TO_TARGET_SINGLE (*CONST_DOUBLE_REAL_VALUE (x), l); x = gen_rtx_REG (SImode, REGNO (operands[0])); - if (! xtensa_constantsynth (x, l[i])) - emit_move_insn (x, GEN_INT (l[i])); + value = (int32_t)l; + if (! xtensa_constantsynth (x, value)) + emit_move_insn (x, GEN_INT (value)); DONE; }) diff --git a/gcc/testsuite/gcc.target/xtensa/constsynth_double.c b/gcc/testsuite/gcc.target/xtensa/constsynth_double.c index 890ca504780..5fba6a98650 100644 --- a/gcc/testsuite/gcc.target/xtensa/constsynth_double.c +++ b/gcc/testsuite/gcc.target/xtensa/constsynth_double.c @@ -5,7 +5,7 @@ void test(unsigned int count, double array[]) { unsigned int i; for (i = 0; i < count; ++i) - array[i] = 1.0; + array[i] = 8.988474246316506e+307; } /* { dg-final { scan-assembler-not "l32r" } } */