Message ID | CAELXzTPsEH67qeYf77dLfQYpEFQ=pFA2n+eXQkcB5qCVRfSmnw@mail.gmail.com |
---|---|
State | New |
Headers | show |
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-44.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-44.c index e69de29..9b12212 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-44.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-44.c @@ -0,0 +1,10 @@ + +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +unsigned int a; +int b, c; +void fn1 () +{ + b = a + c + c; +} diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index fb683ad..06f4d1b 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -525,7 +525,7 @@ sort_by_operand_rank (const void *pa, const void *pb) gimple *stmtb = SSA_NAME_DEF_STMT (oeb->op); basic_block bba = gimple_bb (stmta); basic_block bbb = gimple_bb (stmtb); - if (bbb != bba) + if (bba && bbb && bbb != bba) { if (bb_rank[bbb->index] != bb_rank[bba->index]) return bb_rank[bbb->index] - bb_rank[bba->index];