re PR tree-optimization/86816 (ICE: SIGSEGV in tree-ssa-pre / tail_merge_optimize)
authorRichard Biener <rguenther@suse.de>
Thu, 2 Aug 2018 13:19:50 +0000 (13:19 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 2 Aug 2018 13:19:50 +0000 (13:19 +0000)
2018-08-02  Richard Biener  <rguenther@suse.de>

PR tree-optimization/86816
* tree-ssa-tail-merge.c (tail_merge_valueize): New function
which checks for value availability before querying it.
(gvn_uses_equal): Use it.
(same_succ_hash): Likewise.
(gimple_equal_p): Likewise.

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

From-SVN: r263257

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

index 2a506ee5ffd9f6ff1d5a876f807eee9968ae6a79..e62b9efb2edd873c610257dafcaea726964e84e0 100644 (file)
@@ -1,3 +1,12 @@
+2018-08-02  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/86816
+       * tree-ssa-tail-merge.c (tail_merge_valueize): New function
+       which checks for value availability before querying it.
+       (gvn_uses_equal): Use it.
+       (same_succ_hash): Likewise.
+       (gimple_equal_p): Likewise.
+
 2018-08-02  Nick Clifton  <nickc@redhat.com>
 
        PR target/86789
index cd413d3b02e33bc77465c0254093f3ebfddda621..b0e7505500d0527d1ae73c0c87e6f4f628981243 100644 (file)
@@ -1,3 +1,8 @@
+2018-08-02  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/86816
+       * g++.dg/torture/pr86816.C: New testcase.
+
 2018-08-02  Richard Sandiford  <richard.sandiford@arm.com>
 
        * gcc.target/aarch64/f16_mov_immediate_1.c: Expect fmov immediate
diff --git a/gcc/testsuite/g++.dg/torture/pr86816.C b/gcc/testsuite/g++.dg/torture/pr86816.C
new file mode 100644 (file)
index 0000000..604a7d4
--- /dev/null
@@ -0,0 +1,42 @@
+// { dg-do compile }
+
+class Signal
+{
+public:
+    int  m_Mode;
+};
+
+class Ctx
+{
+public:
+    bool  m_Invert;
+
+    void DoSomething();
+};
+
+class Test
+{
+  void TestIce( Ctx& ctx, Signal* sig);
+};
+
+void Test::TestIce( Ctx& ctx, Signal* sig)
+{
+  int invert = false;
+
+  if( ! ctx.m_Invert)
+    invert = ! invert;
+
+  switch( sig->m_Mode)
+    {
+    case 1:
+    invert = ! invert;
+    break;
+
+    case 2:
+    invert = true;
+    break;
+    }
+
+  if( invert)
+    ctx.DoSomething();
+}
index 15838816d8674429f24bf23a785f6c89e7be28f8..837679a63700e4b1513c30785769a877314a9fbf 100644 (file)
@@ -286,6 +286,21 @@ struct aux_bb_info
 #define BB_VOP_AT_EXIT(bb) (((struct aux_bb_info *)bb->aux)->vop_at_exit)
 #define BB_DEP_BB(bb) (((struct aux_bb_info *)bb->aux)->dep_bb)
 
+/* Valueization helper querying the VN lattice.  */
+
+static tree
+tail_merge_valueize (tree name)
+{
+  if (TREE_CODE (name) == SSA_NAME
+      && has_VN_INFO (name))
+    {
+      tree tem = VN_INFO (name)->valnum;
+      if (tem != VN_TOP)
+       return tem;
+    }
+  return name;
+}
+
 /* Returns true if the only effect a statement STMT has, is to define locally
    used SSA_NAMEs.  */
 
@@ -371,7 +386,7 @@ gvn_uses_equal (tree val1, tree val2)
   if (val1 == val2)
     return true;
 
-  if (vn_valueize (val1) != vn_valueize (val2))
+  if (tail_merge_valueize (val1) != tail_merge_valueize (val2))
     return false;
 
   return ((TREE_CODE (val1) == SSA_NAME || CONSTANT_CLASS_P (val1))
@@ -481,7 +496,7 @@ same_succ_hash (const same_succ *e)
       for (i = 0; i < gimple_call_num_args (stmt); i++)
        {
          arg = gimple_call_arg (stmt, i);
-         arg = vn_valueize (arg);
+         arg = tail_merge_valueize (arg);
          inchash::add_expr (arg, hstate);
        }
     }
@@ -1147,7 +1162,7 @@ gimple_equal_p (same_succ *same_succ, gimple *s1, gimple *s2)
       if (lhs1 == NULL_TREE || lhs2 == NULL_TREE)
        return false;
       if (TREE_CODE (lhs1) == SSA_NAME && TREE_CODE (lhs2) == SSA_NAME)
-       return vn_valueize (lhs1) == vn_valueize (lhs2);
+       return tail_merge_valueize (lhs1) == tail_merge_valueize (lhs2);
       return operand_equal_p (lhs1, lhs2, 0);
 
     case GIMPLE_ASSIGN: