diff options
author | Andrew Pinski <apinski@marvell.com> | 2023-04-09 22:47:50 +0000 |
---|---|---|
committer | Andrew Pinski <apinski@marvell.com> | 2023-04-24 08:50:07 -0700 |
commit | a2339e0fe9dbefdeca49a8105c7a547231c02d34 (patch) | |
tree | 98b15e9e775762052e5eba88b6bace06dc4022bb /gcc/tree-ssa-phiopt.cc | |
parent | 245753249c595af95a811ddb0fe572d93a5dae72 (diff) | |
download | gcc-a2339e0fe9dbefdeca49a8105c7a547231c02d34.zip gcc-a2339e0fe9dbefdeca49a8105c7a547231c02d34.tar.gz gcc-a2339e0fe9dbefdeca49a8105c7a547231c02d34.tar.bz2 |
PHIOPT: Ignore predicates for match-and-simplify phi-opt
This fixes a missed optimization where early phi-opt would
not work when there was predicates. The easiest fix is
to change empty_bb_or_one_feeding_into_p to ignore those
statements while checking for only feeding statement.
Note phi-opt-23.c and phi-opt-24.c still fail as we don't handle
diamond form in match_and_simplify phiopt yet.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
gcc/ChangeLog:
* tree-ssa-phiopt.cc (empty_bb_or_one_feeding_into_p):
Instead of calling last_and_only_stmt, look for the last statement
manually.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/ssa-ifcombine-13.c: Add -fno-ssa-phiopt.
Diffstat (limited to 'gcc/tree-ssa-phiopt.cc')
-rw-r--r-- | gcc/tree-ssa-phiopt.cc | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index f3164b8..f17c350 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -960,9 +960,27 @@ empty_bb_or_one_feeding_into_p (basic_block bb, if (!gimple_seq_empty_p (phi_nodes (bb))) return false; - stmt_to_move = last_and_only_stmt (bb); + gimple_stmt_iterator gsi; + + gsi = gsi_start_nondebug_after_labels_bb (bb); + while (!gsi_end_p (gsi)) + { + gimple *s = gsi_stmt (gsi); + gsi_next_nondebug (&gsi); + /* Skip over Predict and nop statements. */ + if (gimple_code (s) == GIMPLE_PREDICT + || gimple_code (s) == GIMPLE_NOP) + continue; + /* If there is more one statement return false. */ + if (stmt_to_move) + return false; + stmt_to_move = s; + } + + /* The only statement here was a Predict or a nop statement + so return true. */ if (!stmt_to_move) - return false; + return true; if (gimple_vuse (stmt_to_move)) return false; |