[PATCH] D45734: [reassociate] Fix excessive revisits when processing long chains of reassociatable instructions.

Daniel Sanders via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 17 13:20:10 PDT 2018


dsanders created this revision.
Herald added a subscriber: kristof.beyls.

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).

I've yet to run LLVM's test-suite on it. I'll do that next.


Repository:
  rL LLVM

https://reviews.llvm.org/D45734

Files:
  include/llvm/Transforms/Scalar/Reassociate.h
  lib/Transforms/Scalar/Reassociate.cpp
  test/Transforms/Reassociate/long-chains.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45734.142820.patch
Type: text/x-patch
Size: 5492 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180417/d6e5f564/attachment.bin>


More information about the llvm-commits mailing list