re PR middle-end/59993 (ICE: SSA corruption)
authorRichard Biener <rguenther@suse.de>
Thu, 30 Jan 2014 18:28:19 +0000 (18:28 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 30 Jan 2014 18:28:19 +0000 (18:28 +0000)
2014-01-30  Richard Biener  <rguenther@suse.de>

PR tree-optimization/59993
* tree-ssa-forwprop.c (associate_pointerplus): Check we
can propagate form the earlier stmt and avoid the transform
when the intermediate result is needed.

* gcc.dg/torture/pr59993.c: New testcase.

From-SVN: r207316

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr59993.c [new file with mode: 0644]
gcc/tree-ssa-forwprop.c

index 62ac6df..0184dbd 100644 (file)
@@ -1,3 +1,10 @@
+2014-01-30  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/59993
+       * tree-ssa-forwprop.c (associate_pointerplus): Check we
+       can propagate form the earlier stmt and avoid the transform
+       when the intermediate result is needed.
+
 2014-01-30  Alangi Derick  <alangiderick@gmail.com>
 
        * README.Portability: Fix typo.
index 18b2171..6c22615 100644 (file)
@@ -1,3 +1,8 @@
+2014-01-30  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/59993
+       * gcc.dg/torture/pr59993.c: New testcase.
+
 2014-01-30  Richard Sandiford  <rdsandiford@googlemail.com>
 
        * g++.dg/vect/pr33426-ivdep.cc, g++.dg/vect/pr33426-ivdep-2.cc,
diff --git a/gcc/testsuite/gcc.dg/torture/pr59993.c b/gcc/testsuite/gcc.dg/torture/pr59993.c
new file mode 100644 (file)
index 0000000..be55a10
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <setjmp.h>
+
+extern int optind;
+jmp_buf jump_buf;
+int
+main (int argc, char **argv)
+{
+  foo (jump_buf, setjmp(jump_buf));
+  argv += optind;
+  bar(argv[1]);
+}
index ebdd8f5..b229429 100644 (file)
@@ -2926,11 +2926,13 @@ associate_pointerplus (gimple_stmt_iterator *gsi)
   /* Associate (p +p off1) +p off2 as (p +p (off1 + off2)).  */
   ptr = gimple_assign_rhs1 (stmt);
   off1 = gimple_assign_rhs2 (stmt);
-  if (TREE_CODE (ptr) != SSA_NAME)
+  if (TREE_CODE (ptr) != SSA_NAME
+      || !has_single_use (ptr))
     return false;
   def_stmt = SSA_NAME_DEF_STMT (ptr);
   if (!is_gimple_assign (def_stmt)
-      || gimple_assign_rhs_code (def_stmt) != POINTER_PLUS_EXPR)
+      || gimple_assign_rhs_code (def_stmt) != POINTER_PLUS_EXPR
+      || !can_propagate_from (def_stmt))
     return false;
   ptr = gimple_assign_rhs1 (def_stmt);
   off2 = gimple_assign_rhs2 (def_stmt);