re PR rtl-optimization/79388 (wrong code with -O -fno-tree-coalesce-vars)
authorJakub Jelinek <jakub@gcc.gnu.org>
Mon, 13 Feb 2017 15:39:59 +0000 (16:39 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 13 Feb 2017 15:39:59 +0000 (16:39 +0100)
PR rtl-optimization/79388
PR rtl-optimization/79450
* combine.c (distribute_notes): When removing TEM_INSN for which
corresponding dest has last value recorded, invalidate that last
value.

* gcc.c-torture/execute/pr79388.c: New test.
* gcc.c-torture/execute/pr79450.c: New test.

From-SVN: r245390

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr79388.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/pr79450.c [new file with mode: 0644]

index 113328cc828d995954b93a51b3a477378a9a3efd..814b7845f6ffe323be18796a1c91eb4f7ca99544 100644 (file)
@@ -1,3 +1,11 @@
+2017-02-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/79388
+       PR rtl-optimization/79450
+       * combine.c (distribute_notes): When removing TEM_INSN for which
+       corresponding dest has last value recorded, invalidate that last
+       value.
+
 2016-02-13  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * config/arm/arm.c (arm_print_tune_info): Use ASM_COMMENT_START instead
index 727299bdf501d8cf0a9d1d9d5ea1d0df677b89d9..b5c0c184a62724dc77ae195b2918bf27c3a7a1b4 100644 (file)
@@ -14288,6 +14288,11 @@ distribute_notes (rtx notes, rtx_insn *from_insn, rtx_insn *i3, rtx_insn *i2,
                                            NULL_RTX, NULL_RTX, NULL_RTX);
                          distribute_links (LOG_LINKS (tem_insn));
 
+                         unsigned int regno = REGNO (XEXP (note, 0));
+                         reg_stat_type *rsp = &reg_stat[regno];
+                         if (rsp->last_set == tem_insn)
+                           record_value_for_reg (XEXP (note, 0), NULL, NULL_RTX);
+
                          SET_INSN_DELETED (tem_insn);
                          if (tem_insn == i2)
                            i2 = NULL;
index 429fe944fe32e785feb50d50c7a1cc8741b8f565..f4497d5b412453728c426999d4b025d10396ea13 100644 (file)
@@ -1,7 +1,14 @@
+2017-02-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/79388
+       PR rtl-optimization/79450
+       * gcc.c-torture/execute/pr79388.c: New test.
+       * gcc.c-torture/execute/pr79450.c: New test.
+
 2017-02-12  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/65542
-       * gfortran.dg/spread_init_expr_2.f90:  New test case.
+       * gfortran.dg/spread_init_expr_2.f90: New test case.
 
 2017-02-11  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.dg/vect/vect-24.c: Remove xfail on ARM targets.
 
 2017-01-25  Carl Love  <cel@us.ibm.com>
-       * gcc.target/powerpc/builtins-3-p8.c:  Add missing tests for the
+
+       * gcc.target/powerpc/builtins-3-p8.c: Add missing tests for the
        vec_packs built-ins
 
 2017-01-25  Christophe Lyon  <christophe.lyon@linaro.org>
 
 2017-01-23  Thomas Koenig  <tkoenig@netcologne.de>
 
-       * gfortran.dg/integer_exponentiation_7.f90:  New test.
+       * gfortran.dg/integer_exponentiation_7.f90: New test.
 
 2017-01-23  Bernd Schmidt  <bschmidt@redhat.com>
 
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr79388.c b/gcc/testsuite/gcc.c-torture/execute/pr79388.c
new file mode 100644 (file)
index 0000000..07a75c9
--- /dev/null
@@ -0,0 +1,23 @@
+/* PR rtl-optimization/79388 */
+/* { dg-additional-options "-fno-tree-coalesce-vars" } */
+
+unsigned int a, c;
+
+__attribute__ ((noinline, noclone)) unsigned int
+foo (unsigned int p)
+{
+  p |= 1;
+  p &= 0xfffe;
+  p %= 0xffff;
+  c = p;
+  return a + p;
+}
+
+int
+main (void)
+{
+  int x = foo (6);
+  if (x != 6)
+    __builtin_abort();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr79450.c b/gcc/testsuite/gcc.c-torture/execute/pr79450.c
new file mode 100644 (file)
index 0000000..5ba7101
--- /dev/null
@@ -0,0 +1,22 @@
+/* PR rtl-optimization/79450 */
+
+unsigned int
+foo (unsigned char x, unsigned long long y)
+{
+  do
+    {
+      x &= !y;
+      x %= 24;
+    }
+  while (x < y);
+  return x + y;
+}
+
+int
+main (void)
+{
+  unsigned int x = foo (1, 0);
+  if (x != 1)
+    __builtin_abort ();
+  return 0;
+}