Hi,
This is a simple patch fixing ICE in tree-if-conv.c. Existing code does not
setup a variable (cond) when predicate of basic block is true and it asserts on
the variable. Interesting thing is dead code is not cleaned up before ifcvt,
but that's another story.
Bootstrap and test on x86_64. Is it OK?
Thanks,
bin
2016-07-13 Bin Cheng <[email protected]>
PR tree-optimization/71503
PR tree-optimization/71683
* tree-if-conv.c (gen_phi_arg_condition): Set cond when predicate
is true.
gcc/testsuite/ChangeLog
2016-07-13 Bin Cheng <[email protected]>
PR tree-optimization/71503
PR tree-optimization/71683
* gcc.dg/tree-ssa/ifc-pr71503.c: New test.
* gcc.dg/tree-ssa/ifc-pr71683.c: New test.
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index e5a3372..3dce0de 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -1687,7 +1687,11 @@ gen_phi_arg_condition (gphi *phi, vec<int> *occur,
e = gimple_phi_arg_edge (phi, (*occur)[i]);
c = bb_predicate (e->src);
if (is_true_predicate (c))
- continue;
+ {
+ if (!cond)
+ cond = c;
+ continue;
+ }
c = force_gimple_operand_gsi_1 (gsi, unshare_expr (c),
is_gimple_condexpr, NULL_TREE,
true, GSI_SAME_STMT);
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ifc-pr71503.c
b/gcc/testsuite/gcc.dg/tree-ssa/ifc-pr71503.c
new file mode 100644
index 0000000..5a90abf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ifc-pr71503.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast" { target *-*-* } } */
+
+int a, b;
+unsigned long d;
+void fn1() {
+ unsigned long *h = &d;
+line1 : {
+ int i = 4;
+ for (; b; i++) {
+ d = ((d + 6 ?: *h) ? a : 7) && (i &= 0 >= b);
+ b += a;
+ }
+}
+ h = 0;
+ for (; *h;)
+ goto line1;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ifc-pr71683.c
b/gcc/testsuite/gcc.dg/tree-ssa/ifc-pr71683.c
new file mode 100644
index 0000000..851be37
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ifc-pr71683.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast" { target *-*-* } } */
+
+short unsigned int ve;
+
+void
+u1 (void)
+{
+ int oq = 0;
+
+ while (ve != 0)
+ {
+ int j4, w7 = oq;
+
+ oq = 0 / oq;
+ ve %= oq;
+ j4 = ve ^ 1;
+ ve ^= oq;
+ if (j4 != 0 ? j4 : ve)
+ oq = ve;
+ else
+ if (w7 != 0)
+ oq = ve;
+ }
+}