llvm-project/llvm/test/Transforms/Reassociate
Daniel Sanders 8d0d1aa229 [reassociate] Fix excessive revisits when processing long chains of reassociatable instructions.
Summary:
Some of our internal testing detected a major compile time regression which I've
tracked down to:
    r278938 - Revert "Reassociate: Reprocess RedoInsts after each inst".
It appears that processing long chains of reassociatable instructions causes
non-linear (potentially exponential) growth in the number of times an
instruction is revisited. For example, the included test revisits instructions
220 times in a 20-instruction test.

It appears that r278938 reversed the order instructions were visited and that
this is preventing scheduled revisits from being cancelled as a result of
visiting the instructions naturally during normal processing. However, simply
reversing the order also harmed the generated code. Upon closer inspection, it
was discovered that revisits occurred in the opposite order to the first pass
(Thanks to escha for spotting that).

This patch makes the revisit order consistent with the first pass which allows
more revisits to be cancelled. This does appear to have a small impact on the
generated code in few cases but it significantly reduces compile-time.

After this patch, our internal test that was most affected by the regression
dropped from ~2 million revisits to ~4k resulting in Reassociate having 0.46%
of the runtime it had before (99.54% improvement).

Here's the summaries reported by lnt for the LLVM test-suite with --benchmarking-only:
| metric         | geomean before patch | geomean after patch | delta   |
| -----          | -----                | -----               | -----   |
| compile time   | 0.1956               | 0.1261              | -35.54% |
| execution time | 0.3240               | 0.3237              | -       |
| code size      | 7365.4459            | 7365.6079           | -       |

The results have a few wins and losses on compile-time, mostly in the +/- 2.5% range. There was one outlier though:
| Performance Regressions - compile_time | Δ | Previous | Current |
| MultiSource/Benchmarks/ASC_Sequoia/CrystalMk/CrystalMk | 9.82% | 2.0473 | 2.2483 |

Reviewers: javed.absar, dberlin

Reviewed By: dberlin

Subscribers: kristof.beyls, llvm-commits

Differential Revision: https://reviews.llvm.org/D45734

llvm-svn: 331381
2018-05-02 17:59:16 +00:00
..
2002-05-15-AgressiveSubMove.ll
2002-05-15-MissedTree.ll
2002-05-15-SubReassociate.ll
2002-07-09-DominanceProblem.ll
2003-08-12-InfiniteLoop.ll
2005-09-01-ArrayOutOfBounds.ll
2006-04-27-ReassociateVector.ll
2011-01-26-UseAfterFree.ll
2012-05-08-UndefLeak.ll
2012-06-08-InfiniteLoop.ll
absorption.ll
add_across_block_crash.ll [Reassociate] add check lines; NFC 2017-11-09 16:25:35 +00:00
basictest.ll Reassociate: add global reassociation algorithm 2017-12-12 19:18:02 +00:00
canonicalize-neg-const.ll [Reassociate] regenerate test checks; NFC 2017-11-09 16:30:19 +00:00
commute.ll
crash.ll
crash2.ll [Reassociate] fix test to be independent of FP undef 2018-03-08 22:05:27 +00:00
deadcode.ll
erase_inst_made_change.ll
factorize-again.ll [ConstantFold] fp_binop undef, undef --> undef 2018-03-08 20:42:49 +00:00
fast-AgressiveSubMove.ll [Reassociate] add tests with 'reassoc' FMF; NFC 2017-11-13 17:29:11 +00:00
fast-ArrayOutOfBounds.ll
fast-MissedTree.ll [InstCombine] Enable Add/Sub simplifications with only 'reassoc' FMF 2018-04-14 19:18:28 +00:00
fast-ReassociateVector.ll Reassociate: add global reassociation algorithm 2017-12-12 19:18:02 +00:00
fast-SubReassociate.ll [InstCombine] Enable Add/Sub simplifications with only 'reassoc' FMF 2018-04-14 19:18:28 +00:00
fast-basictest.ll [InstCombine] Enable Add/Sub simplifications with only 'reassoc' FMF 2018-04-14 19:18:28 +00:00
fast-fp-commute.ll Reassociate: add global reassociation algorithm 2017-12-12 19:18:02 +00:00
fast-mightymul.ll
fast-multistep.ll [Reassociate] don't name values "tmp"; NFCI 2017-11-09 18:14:24 +00:00
fp-commute.ll
fp-expr.ll [ConstantFold] fp_binop undef, undef --> undef 2018-03-08 20:42:49 +00:00
inverses.ll
keep-debug-loc.ll
long-chains.ll [reassociate] Fix excessive revisits when processing long chains of reassociatable instructions. 2018-05-02 17:59:16 +00:00
looptest.ll
matching-binops.ll [Reassociate] add a test with debug info; NFC 2018-04-27 21:14:15 +00:00
mightymul.ll
min_int.ll
mixed-fast-nonfast-fp.ll [Reassociate] add tests with 'reassoc' FMF; NFC 2017-11-13 17:29:11 +00:00
mulfactor.ll [Reassociate] don't name values "tmp"; NFCI 2017-11-09 18:14:24 +00:00
multistep.ll [Reassociate] don't name values "tmp"; NFCI 2017-11-09 18:14:24 +00:00
negation.ll
negation1.ll
no-op.ll
optional-flags.ll
otherops.ll
pr12245.ll
pr21205.ll
pr28367.ll
propagate-flags.ll [Reassociate] regenerate test checks; NFC 2017-11-09 22:41:39 +00:00
reassoc-intermediate-fnegs.ll [Reassociate] don't name values "tmp"; NFCI 2017-11-09 18:14:24 +00:00
reassociate-deadinst.ll
reassociate_dbgvalue_discard.ll [DebugInfo] Invalidate debug info in ReassociatePass::RewriteExprTree 2018-04-25 09:23:56 +00:00
repeats.ll
secondary.ll
shift-factor.ll [Reassociate] don't name values "tmp"; NFCI 2017-11-09 18:14:24 +00:00
shifttest.ll
subtest.ll
vaarg_movable.ll
wrap-flags.ll
xor_reassoc.ll