public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Max Filippov <jcmvbkbc@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-1691] xtensa: Minor fix for FP constant synthesis
Date: Thu, 14 Jul 2022 07:24:00 +0000 (GMT)	[thread overview]
Message-ID: <20220714072400.2EC31385740C@sourceware.org> (raw)

https://gcc.gnu.org/g:e85c94d1c83072d7b894e44009e876dd41ff778a

commit r13-1691-ge85c94d1c83072d7b894e44009e876dd41ff778a
Author: Takayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp>
Date:   Wed Jul 13 20:40:13 2022 +0900

    xtensa: Minor fix for FP constant synthesis
    
    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.

Diff:
---
 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" } } */


                 reply	other threads:[~2022-07-14  7:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220714072400.2EC31385740C@sourceware.org \
    --to=jcmvbkbc@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).