]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
alpha: Fix computation mode in alpha_emit_set_long_cost [PR106966]
authorUros Bizjak <ubizjak@gmail.com>
Thu, 13 Jul 2023 16:32:15 +0000 (18:32 +0200)
committerUros Bizjak <ubizjak@gmail.com>
Thu, 13 Jul 2023 16:32:15 +0000 (18:32 +0200)
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.

gcc/config/alpha/alpha.cc
gcc/testsuite/gcc.target/alpha/pr106966.c [new file with mode: 0644]

index 360b50e20d4e6117c3a10c48a4bc57c21754c71b..beeab06a1aa5535a4d5dd87f4210916290194744 100644 (file)
@@ -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 (file)
index 0000000..7145c20
--- /dev/null
@@ -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';
+}