IndVarSimplify may simplify branch conditions for blocks in loops, but
does not simplify conditional to unconditional branches.
This can pessimize later passes, like loop-delete, which check for
certain conditions across all blocks in a loop. This results in cases
where we fail to delete or vectorize loops, e.g. because they contain
dynamically dead blocks with calls with side effects.
Fixes #29339 (improved optimization).
It also can improve compile-time drastically by cleaning up blocks and branches after IndVarSimplify.
Fixes #49675 (slow compile time)
Fixes #51264 (slow compile time)
Fixes #51295 (slow compile time)
Compile-time impact:
- O3 geomean: +0.04%
- O3 ThinLTO: +0.09%
- O3 LTO : +0.19%
This shakes up quite a few things, with quite a few stats changes across
MultiSource/SPEC2000/SPEC2006 on X86 with -flto -O3
e.g.
Same hash: 203 (filtered out) Remaining: 34 Metric: loop-vectorize.LoopsVectorized Program base patch diff test-suite...6/464.h264ref/464.h264ref.test 156.00 159.00 1.9% test-suite...marks/7zip/7zip-benchmark.test 336.00 341.00 1.5% test-suite...T2006/445.gobmk/445.gobmk.test 90.00 90.00 0.0% test-suite...ProxyApps-C++/CLAMR/CLAMR.test 196.00 196.00 0.0% Same hash: 203 (filtered out) Remaining: 34 Metric: scalar-evolution.NumTripCountsComputed Program base patch diff test-suite...nch/fourinarow/fourinarow.test 64.00 81.00 26.6% test-suite...6/464.h264ref/464.h264ref.test 5330.00 5969.00 12.0% test-suite...cations/hexxagon/hexxagon.test 77.00 84.00 9.1% test-suite...ications/JM/lencod/lencod.test 5227.00 5660.00 8.3% test-suite...ications/JM/ldecod/ldecod.test 2396.00 2592.00 8.2% test-suite.../Prolangs-C/loader/loader.test 13.00 14.00 7.7% test-suite...nal/skidmarks10/skidmarks.test 933.00 993.00 6.4% test-suite...lications/viterbi/viterbi.test 49.00 52.00 6.1% test-suite...nsumer-lame/consumer-lame.test 1715.00 1779.00 3.7% test-suite...T2006/445.gobmk/445.gobmk.test 2611.00 2687.00 2.9% test-suite...marks/7zip/7zip-benchmark.test 4512.00 4642.00 2.9% test-suite...CI_Purple/SMG2000/smg2000.test 2007.00 2057.00 2.5% test-suite...CFP2000/188.ammp/188.ammp.test 741.00 759.00 2.4% test-suite...006/453.povray/453.povray.test 2504.00 2560.00 2.2% test-suite...:: External/Povray/povray.test 2583.00 2633.00 1.9% test-suite.../CINT2000/176.gcc/176.gcc.test 2602.00 2650.00 1.8% test-suite...abench/jpeg/jpeg-6a/cjpeg.test 1307.00 1326.00 1.5% test-suite...nsumer-jpeg/consumer-jpeg.test 1332.00 1351.00 1.4% test-suite...TimberWolfMC/timberwolfmc.test 1283.00 1299.00 1.2% test-suite...006/447.dealII/447.dealII.test 22333.00 22579.00 1.1% test-suite...T2006/456.hmmer/456.hmmer.test 1671.00 1688.00 1.0% test-suite...ternal/HMMER/hmmcalibrate.test 1672.00 1689.00 1.0% test-suite...peg2/mpeg2dec/mpeg2decode.test 497.00 502.00 1.0%