re PR tree-optimization/63380 (Wrong constant folding)
authorRichard Biener <rguenther@suse.de>
Thu, 9 Oct 2014 12:45:07 +0000 (12:45 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 9 Oct 2014 12:45:07 +0000 (12:45 +0000)
2014-10-09  Richard Biener  <rguenther@suse.de>

PR tree-optimization/63380
* tree-ssa-tail-merge.c (stmt_local_def): Exclude stmts that
may trap.

* gcc.dg/torture/pr63380-1.c: New testcase.
* gcc.dg/torture/pr63380-2.c: Likewise.

From-SVN: r216038

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr63380-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr63380-2.c [new file with mode: 0644]
gcc/tree-ssa-tail-merge.c

index 5300c01190483d2079179241fdbffad296fe685e..23d7bbe4f4c5f1726f0e7d94f74c7e08c0bad230 100644 (file)
@@ -1,3 +1,9 @@
+2014-10-09  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/63380
+       * tree-ssa-tail-merge.c (stmt_local_def): Exclude stmts that
+       may trap.
+
 2014-10-09  Joern Rennecke  <joern.rennecke@embecosm.com>
 
        * config/avr/avr.opt (mmcu=): Change to have a string value.
index ea731bf0abd3240ddc4c36156573776714213d10..0cee7d6cf62834a672edb6317da85418c136a972 100644 (file)
@@ -1,3 +1,9 @@
+2014-10-09  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/63380
+       * gcc.dg/torture/pr63380-1.c: New testcase.
+       * gcc.dg/torture/pr63380-2.c: Likewise.
+
 2014-10-09  Marek Polacek  <polacek@redhat.com>
 
        PR c/63480
diff --git a/gcc/testsuite/gcc.dg/torture/pr63380-1.c b/gcc/testsuite/gcc.dg/torture/pr63380-1.c
new file mode 100644 (file)
index 0000000..29defac
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do run } */
+
+int a = 0, b = 1, c = 0, d = 1, e, f, g, h;
+int
+main ()
+{
+  e = 1 >> d;
+  f = ((31 / (1 > e)) || c) / 2;
+  g = b || a;
+  h = 31 / g;
+  if (!h)
+    __builtin_abort();
+  return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr63380-2.c b/gcc/testsuite/gcc.dg/torture/pr63380-2.c
new file mode 100644 (file)
index 0000000..f4cbc43
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do run } */
+
+int a = 0, b = 0, c = 0, d, e;
+int
+main (void)
+{
+  d = ((20 % (1 != b)) && c) + 2147483647;
+  e = 20 % (a >= 0);
+  return 0;
+}
index 5615c7914213933357cb39972c678b85a2f3a1e1..37181bd6c74acd57d0dc28a0f0c468ea089841f5 100644 (file)
@@ -313,9 +313,9 @@ stmt_local_def (gimple stmt)
   tree val;
   def_operand_p def_p;
 
-  if (gimple_has_side_effects (stmt)
-      || stmt_could_throw_p (stmt)
-      || gimple_vdef (stmt) != NULL_TREE)
+  if (gimple_vdef (stmt) != NULL_TREE
+      || gimple_has_side_effects (stmt)
+      || gimple_could_trap_p_1 (stmt, false, false))
     return false;
 
   def_p = SINGLE_SSA_DEF_OPERAND (stmt, SSA_OP_DEF);