public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-9770] alpha: Fix computation mode in alpha_emit_set_long_cost [PR106966]
@ 2023-07-13 16:34 Uros Bizjak
  0 siblings, 0 replies; only message in thread
From: Uros Bizjak @ 2023-07-13 16:34 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:4520e2dbc73262028ad556f732871565101ef615

commit r12-9770-g4520e2dbc73262028ad556f732871565101ef615
Author: Uros Bizjak <ubizjak@gmail.com>
Date:   Thu Jul 13 18:32:15 2023 +0200

    alpha: Fix computation mode in alpha_emit_set_long_cost [PR106966]
    
            PR target/106966
    
    gcc/ChangeLog:
    
            * config/alpha/alpha.cc (alpha_emit_set_long_const):
            Always use DImode when constructing long const.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/alpha/pr106966.c: New test.
    
    (cherry picked from commit 337649c1660211db733c1ba34ae260b8c66a3578)

Diff:
---
 gcc/config/alpha/alpha.cc                 |  7 ++++++-
 gcc/testsuite/gcc.target/alpha/pr106966.c | 13 +++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/gcc/config/alpha/alpha.cc b/gcc/config/alpha/alpha.cc
index 0a85e66fa89..06c8356fc4e 100644
--- a/gcc/config/alpha/alpha.cc
+++ b/gcc/config/alpha/alpha.cc
@@ -2070,6 +2070,8 @@ static rtx
 alpha_emit_set_long_const (rtx target, HOST_WIDE_INT c1)
 {
   HOST_WIDE_INT d1, d2, d3, d4;
+  machine_mode mode = GET_MODE (target);
+  rtx orig_target = target;
 
   /* Decompose the entire word */
 
@@ -2082,6 +2084,9 @@ alpha_emit_set_long_const (rtx target, HOST_WIDE_INT c1)
   d4 = ((c1 & 0xffffffff) ^ 0x80000000) - 0x80000000;
   gcc_assert (c1 == d4);
 
+  if (mode != DImode)
+    target = gen_lowpart (DImode, target);
+
   /* Construct the high word */
   if (d4)
     {
@@ -2101,7 +2106,7 @@ alpha_emit_set_long_const (rtx target, HOST_WIDE_INT c1)
   if (d1)
     emit_move_insn (target, gen_rtx_PLUS (DImode, target, GEN_INT (d1)));
 
-  return target;
+  return orig_target;
 }
 
 /* Given an integral CONST_INT or CONST_VECTOR, return the low 64 bits.  */
diff --git a/gcc/testsuite/gcc.target/alpha/pr106966.c b/gcc/testsuite/gcc.target/alpha/pr106966.c
new file mode 100644
index 00000000000..7145c2096c6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/alpha/pr106966.c
@@ -0,0 +1,13 @@
+/* PR target/106906 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -mbuild-constants" } */
+
+void
+do_console (unsigned short *vga)
+{
+  vga[0] = 'H';
+  vga[1] = 'e';
+  vga[2] = 'l';
+  vga[3] = 'l';
+  vga[4] = 'o';
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-13 16:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-13 16:34 [gcc r12-9770] alpha: Fix computation mode in alpha_emit_set_long_cost [PR106966] Uros Bizjak

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).