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 66396a0..20f8d0d 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 64638c5..c007611 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 39ad0c5..2556b0c 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;
 }