re PR tree-optimization/87124 (ICE have integer_cst in SSA_VAL, at tree-ssa-sccvn...
authorRichard Biener <rguenther@suse.de>
Tue, 28 Aug 2018 13:36:49 +0000 (13:36 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 28 Aug 2018 13:36:49 +0000 (13:36 +0000)
2018-08-28  Richard Biener  <rguenther@suse.de>

PR tree-optimization/87124
* tree-ssa-sccvn.c (vn_lookup_simplify_result): Guard against
constants before looking up avail.

* g++.dg/torture/pr87124.C: New testcase.

From-SVN: r263918

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr87124.C [new file with mode: 0644]
gcc/tree-ssa-sccvn.c

index 66396a0a4d3a594877c127ab2b975a9d4e8620db..20f8d0d50be1033415866bd2be7424a953107c16 100644 (file)
@@ -1,3 +1,9 @@
+2018-08-28  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/87124
+       * tree-ssa-sccvn.c (vn_lookup_simplify_result): Guard against
+       constants before looking up avail.
+
 2018-08-28  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/87099
index 64638c544f125a28a7921f42b00e9ca91dbcc624..c00761123a6cc939cbfc79befe38dc295cd24925 100644 (file)
@@ -1,3 +1,8 @@
+2018-08-28  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/87124
+       * g++.dg/torture/pr87124.C: New testcase.
+
 2017-08-28  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/80477
diff --git a/gcc/testsuite/g++.dg/torture/pr87124.C b/gcc/testsuite/g++.dg/torture/pr87124.C
new file mode 100644 (file)
index 0000000..3e7d480
--- /dev/null
@@ -0,0 +1,12 @@
+// { dg-do compile }
+
+class A {
+    void m_fn1();
+};
+
+void A::m_fn1()
+{
+  A *a = this;
+  for (int i; i && a;)
+    a = 0;
+}
index 39ad0c595ac2ec6909b3391250cb3809f92ad052..2556b0c45271a3019421216b9a47b09383f64966 100644 (file)
@@ -5667,7 +5667,7 @@ vn_lookup_simplify_result (gimple_match_op *res_op)
                                       res_op->type, ops, &vnresult);
   /* If this is used from expression simplification make sure to
      return an available expression.  */
-  if (res && mprts_hook && rpo_avail)
+  if (res && TREE_CODE (res) == SSA_NAME && mprts_hook && rpo_avail)
     res = rpo_avail->eliminate_avail (vn_context_bb, res);
   return res;
 }