diff --git a/gcc/gimple-match-head.cc b/gcc/gimple-match-head.cc index b63b66e9485a2e1b796bbac9ebbed0a823b75206..b5d4a71ddc55f054e6ee15c1553577a3b6634a85 100644 --- a/gcc/gimple-match-head.cc +++ b/gcc/gimple-match-head.cc @@ -402,7 +402,7 @@ match_cond_with_binary_phi (gphi *phi, tree *true_arg, tree *false_arg) if (EDGE_COUNT (pred_b0->succs) == 2 && EDGE_COUNT (pred_b1->succs) == 1 && EDGE_COUNT (pred_b1->preds) == 1 - && pred_b0 == EDGE_PRED (gimple_bb (phi), 0)->src) + && pred_b0 == EDGE_PRED (pred_b1, 0)->src) /* * +------+ * | b0: | diff --git a/gcc/testsuite/gcc.dg/torture/pr116795-1.c b/gcc/testsuite/gcc.dg/torture/pr116795-1.c new file mode 100644 index 0000000000000000000000000000000000000000..629bdf4bacdafdc1418e560a3ab008699813140c --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr116795-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +volatile int a, b; +int c; +int main() { + unsigned e = 0; + for (; e < 2; e++) { + a && b; + if (c) + e = -(c ^ e); + } + return 0; +}