diff mbox

Fix PR63380

Message ID alpine.LSU.2.11.1410091059140.20733@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Oct. 9, 2014, 9 a.m. UTC
The following fixes PR63380 by making sure to not ignore unused
but possibly trapping stmts when comparing basic-blocks.

Bootstrap / regtest running on x86_64-unknown-linux-gnu.

Richard.

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.
diff mbox

Patch

Index: gcc/tree-ssa-tail-merge.c
===================================================================
--- gcc/tree-ssa-tail-merge.c	(revision 215917)
+++ gcc/tree-ssa-tail-merge.c	(working copy)
@@ -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);
Index: gcc/testsuite/gcc.dg/torture/pr63380-1.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr63380-1.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr63380-1.c	(working copy)
@@ -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;
+}
+
Index: gcc/testsuite/gcc.dg/torture/pr63380-2.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr63380-2.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr63380-2.c	(working copy)
@@ -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;
+}