re PR tree-optimization/82276 (-O2: ICE: SSA corruption during RTL pass: expand;...
authorRichard Biener <rguenther@suse.de>
Thu, 21 Sep 2017 12:12:33 +0000 (12:12 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 21 Sep 2017 12:12:33 +0000 (12:12 +0000)
2017-09-21  Richard Biener  <rguenther@suse.de>

PR tree-optimization/82276
PR tree-optimization/82244
* tree-vrp.c (build_assert_expr_for): Set
SSA_NAME_OCCURS_IN_ABNORMAL_PHI if the variable we assert on
has it set.
(remove_range_assertions): Revert earlier change.

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

From-SVN: r253062

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr82276.c [new file with mode: 0644]
gcc/tree-vrp.c

index c7065000c7d3bba53aab4bb7c820c91f1466c26a..736cc7f29f4d7e5374dec5bee3255c5f2ef2c4ea 100644 (file)
@@ -1,3 +1,12 @@
+2017-09-21  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/82276
+       PR tree-optimization/82244
+       * tree-vrp.c (build_assert_expr_for): Set
+       SSA_NAME_OCCURS_IN_ABNORMAL_PHI if the variable we assert on
+       has it set.
+       (remove_range_assertions): Revert earlier change.
+
 2017-09-21  Wilco Dijkstra  <wdijkstr@arm.com>
 
        PR target/71951
index 870d2543179414df26b0634b431f51d283568b61..3db0548a8389da996838cb57363fe5b48808a97a 100644 (file)
@@ -1,3 +1,9 @@
+2017-09-21  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/82276
+       PR tree-optimization/82244
+       * gcc.dg/torture/pr82276.c: New testcase.
+
 2017-09-21  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/71351
diff --git a/gcc/testsuite/gcc.dg/torture/pr82276.c b/gcc/testsuite/gcc.dg/torture/pr82276.c
new file mode 100644 (file)
index 0000000..2f9efc8
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+
+typedef struct a {
+  struct a *b;
+} a;
+
+extern int d(void);
+extern int g(void);
+extern int h(void);
+extern int _setjmp();
+extern int i(void);
+
+void c(void) {
+    1 ? d() : 0;
+    a *e;
+    while (e) {
+       e = (e == (a *) c) ? 0 : e->b;
+       while (e) {
+           unsigned int f = 0;
+           g();
+           _setjmp(f);
+           if (f & 6) {
+               ;
+           } else if (f & 2) {
+               ;
+           } else {
+               h();
+           }
+           i();
+       }
+    }
+}
index 1d45851ea924ddfdd5cc190e6a24fcf69149b294..aef20f4e8a5a71336c39d5186848904dff9c8623 100644 (file)
@@ -4520,7 +4520,12 @@ build_assert_expr_for (tree cond, tree v)
      operand of the ASSERT_EXPR.  Create it so the new name and the old one
      are registered in the replacement table so that we can fix the SSA web
      after adding all the ASSERT_EXPRs.  */
-  create_new_def_for (v, assertion, NULL);
+  tree new_def = create_new_def_for (v, assertion, NULL);
+  /* Make sure we preserve abnormalness throughout an ASSERT_EXPR chain
+     given we have to be able to fully propagate those out to re-create
+     valid SSA when removing the asserts.  */
+  if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (v))
+    SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_def) = 1;
 
   return assertion;
 }
@@ -7041,14 +7046,6 @@ remove_range_assertions (void)
                  FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
                    SET_USE (use_p, var);
              }
-           /* But do not propagate constants as that is invalid.  */
-           else if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs))
-             {
-               gassign *ass = gimple_build_assign (lhs, var);
-               gsi_replace (&si, ass, true);
-               gsi_next (&si);
-               continue;
-             }
            else
              replace_uses_by (lhs, var);