]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR rtl-optimization/89679
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 14 Mar 2019 12:21:36 +0000 (12:21 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 14 Mar 2019 12:21:36 +0000 (12:21 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@269680 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 329954b78ac72d5b1adef7b2c4f6df0b220df4a3..fb9a555b59aa7dfc5ba8b54a6211c1110ef3eb0e 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2019-03-14  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/89710
index b7f55a7e73b560e47fa7c6739e02b0a71246ea58..d7f8e9a5d767fa9d607312c73f8e36d10f3e610a 100644 (file)
@@ -3356,13 +3356,20 @@ expand_mult_const (machine_mode mode, rtx op0, HOST_WIDE_INT val,
              tem = gen_lowpart (nmode, op0);
            }
 
-         insn = get_last_insn ();
-         wide_int wval_so_far
-           = wi::uhwi (val_so_far,
-                       GET_MODE_PRECISION (as_a <scalar_mode> (nmode)));
-         rtx c = immed_wide_int_const (wval_so_far, nmode);
-         set_dst_reg_note (insn, REG_EQUAL, gen_rtx_MULT (nmode, tem, c),
-                           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 ();
+             wide_int wval_so_far
+               = wi::uhwi (val_so_far,
+                           GET_MODE_PRECISION (as_a <scalar_mode> (nmode)));
+             rtx c = immed_wide_int_const (wval_so_far, nmode);
+             set_dst_reg_note (insn, REG_EQUAL, gen_rtx_MULT (nmode, tem, c),
+                               accum_inner);
+           }
        }
     }
 
index 3536cf145e22ad672865957f1e7850fa6a03cf7e..19c319e06918d6f27e16aab405cd0265d5bebab2 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/89679
+       * gcc.dg/pr89679.c: New test.
+
 2019-03-14  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/89710
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;
+}