From 04ac4afa844abb88a4a3bddd9dbfe5572d38aea4 Mon Sep 17 00:00:00 2001 From: Bin Cheng Date: Wed, 20 Jul 2016 08:31:35 +0000 Subject: [PATCH] re PR tree-optimization/71503 (gcc ICE at -O3 on valid code on x86_64-linux-gnu in "gen_phi_arg_condition") PR tree-optimization/71503 PR tree-optimization/71683 * tree-if-conv.c (gen_phi_arg_condition): Record true predicate and break. gcc/testsuite 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. From-SVN: r238512 --- gcc/ChangeLog | 7 ++++++ gcc/testsuite/ChangeLog | 7 ++++++ gcc/testsuite/gcc.dg/tree-ssa/ifc-pr71503.c | 18 +++++++++++++++ gcc/testsuite/gcc.dg/tree-ssa/ifc-pr71683.c | 25 +++++++++++++++++++++ gcc/tree-if-conv.c | 5 ++++- 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/ifc-pr71503.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/ifc-pr71683.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 82a473794e5..0b2eac8bccf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-07-20 Bin Cheng + + PR tree-optimization/71503 + PR tree-optimization/71683 + * tree-if-conv.c (gen_phi_arg_condition): Record true predicate + and break. + 2016-07-20 Martin Liska * doc/invoke.texi (-fipa-ra): Document when the option is diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7f42fad4064..e631db95057 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2016-07-20 Bin Cheng + + 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. + 2016-07-20 Martin Liska * gcc.dg/plugin/plugin.exp: Remove sreal test. 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 00000000000..5a90abfd10e --- /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 00000000000..851be37e48c --- /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; + } +} diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index e5a3372cd4e..4253d194ed4 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -1687,7 +1687,10 @@ gen_phi_arg_condition (gphi *phi, vec *occur, e = gimple_phi_arg_edge (phi, (*occur)[i]); c = bb_predicate (e->src); if (is_true_predicate (c)) - continue; + { + cond = c; + break; + } c = force_gimple_operand_gsi_1 (gsi, unshare_expr (c), is_gimple_condexpr, NULL_TREE, true, GSI_SAME_STMT); -- 2.30.2