]> gcc.gnu.org Git - gcc.git/commitdiff
backport: re PR rtl-optimization/89679 (wrong code with -Og -frerun-cse-after-loop...
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 12:19:33 +0000 (14:19 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 12:19:33 +0000 (14:19 +0200)
Backported from mainline
2019-03-14  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/89679
* expmed.c (expand_mult_const): Don't add a REG_EQUAL note if it
would contain a paradoxical SUBREG.

* gcc.dg/pr89679.c: New test.

From-SVN: r275132

gcc/ChangeLog
gcc/expmed.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr89679.c [new file with mode: 0644]

index 1be99eebeef22396debe1dfbf5f4e72b40572990..37e1a9fe8efc18d7904c6485cc10d71393d2187c 100644 (file)
@@ -3,6 +3,10 @@
        Backported from mainline
        2019-03-14  Jakub Jelinek  <jakub@redhat.com>
 
+       PR rtl-optimization/89679
+       * expmed.c (expand_mult_const): Don't add a REG_EQUAL note if it
+       would contain a paradoxical SUBREG.
+
        PR tree-optimization/89703
        * tree-ssa-strlen.c (valid_builtin_call): Punt if stmt call types
        aren't compatible also with builtin_decl_explicit.  Check pure
index b9f12576b0cf0c07b44de8a2e207628b85326a34..06a06d1a0cc0afffd86e6bad54ea01bdf95183b2 100644 (file)
@@ -3179,11 +3179,19 @@ expand_mult_const (machine_mode mode, rtx op0, HOST_WIDE_INT val,
              tem = gen_lowpart (nmode, op0);
            }
 
-          insn = get_last_insn ();
-          set_dst_reg_note (insn, REG_EQUAL,
-                           gen_rtx_MULT (nmode, tem,
-                                         gen_int_mode (val_so_far, nmode)),
-                           accum_inner);
+         /* Don't add a REG_EQUAL note if tem is a paradoxical SUBREG.
+            In that case, only the low bits of accum would be guaranteed to
+            be equal to the content of the REG_EQUAL note, the upper bits
+            can be anything.  */
+         if (!paradoxical_subreg_p (tem))
+           {
+             insn = get_last_insn ();
+             set_dst_reg_note (insn, REG_EQUAL,
+                               gen_rtx_MULT (nmode, tem,
+                                             gen_int_mode (val_so_far,
+                                                           nmode)),
+                               accum_inner);
+           }
        }
     }
 
index e5525de68184f1c3d756c34924f731dbf41ee418..d9fdc68c19efa8414472d204f1eb9ea261753cbd 100644 (file)
@@ -3,6 +3,9 @@
        Backported from mainline
        2019-03-14  Jakub Jelinek  <jakub@redhat.com>
 
+       PR rtl-optimization/89679
+       * gcc.dg/pr89679.c: New test.
+
        PR tree-optimization/89703
        * gcc.c-torture/compile/pr89703-1.c: New test.
        * gcc.c-torture/compile/pr89703-2.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr89679.c b/gcc/testsuite/gcc.dg/pr89679.c
new file mode 100644 (file)
index 0000000..0d6e2d2
--- /dev/null
@@ -0,0 +1,26 @@
+/* PR rtl-optimization/89679 */
+/* { dg-do run } */
+/* { dg-options "-Og -frerun-cse-after-loop -fno-tree-fre" } */
+
+unsigned short g;
+
+void
+foo (unsigned long long x)
+{
+  if (x != 0xffff)
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+#if __SIZEOF_SHORT__ == 2 && __SIZEOF_INT__ == 4 && __CHAR_BIT__ == 8
+  unsigned short d = 0;
+  unsigned long long x, c = ~0;
+  c = c >> d;
+  __builtin_memset (&d, c, 2);
+  x = d + g;
+  foo (x);
+#endif
+  return 0;
+}
This page took 0.092524 seconds and 5 git commands to generate.