aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-03-14 13:21:36 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-03-14 13:21:36 +0100
commit87654f1813a0f582645f72d87f7fb8c78b92ee6a (patch)
tree40dbf553b569f68381f8ca699e138c8daac87caa
parentdf6d3ac9aa35d4d9cd23bc70e961490c19e2477d (diff)
downloadgcc-87654f1813a0f582645f72d87f7fb8c78b92ee6a.zip
gcc-87654f1813a0f582645f72d87f7fb8c78b92ee6a.tar.gz
gcc-87654f1813a0f582645f72d87f7fb8c78b92ee6a.tar.bz2
re PR rtl-optimization/89679 (wrong code with -Og -frerun-cse-after-loop -fno-tree-fre)
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: r269680
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/expmed.c21
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr89679.c26
4 files changed, 51 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 329954b..fb9a555 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/expmed.c b/gcc/expmed.c
index b7f55a7..d7f8e9a 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -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);
+ }
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3536cf1..19c319e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..0d6e2d2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr89679.c
@@ -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;
+}