This is an archive of the discontinued LLVM Phabricator instance.

[WIP][InstCombine] Enhance the sinking to handle multiple uses
Needs ReviewPublic

Authored by hyeongyukim on Jul 31 2021, 9:47 AM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

This change will enhance InstCombine to sink more instructions.
Currently, only single-use instructions are sinking, and this
change will allow multiple uses to sink as well.

Diff Detail

Event Timeline

hyeongyukim created this revision.Jul 31 2021, 9:47 AM
hyeongyukim requested review of this revision.Jul 31 2021, 9:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2021, 9:47 AM
hyeongyukim retitled this revision from [InstCombine] Enhance the sinking to handle multiple uses to [WIP][InstCombine] Enhance the sinking to handle multiple uses.Jul 31 2021, 9:51 AM

The test files below should be modified manually.

Transforms/LoopVectorize/first-order-recurrence.ll
Transforms/LoopVectorize/float-induction.ll
Transforms/InstCombine/intptr7.ll

I will remove the WIP after modifying these files.

Thanks for trying, but yikes.
Like i expected, this has a pretty interesting effect on the compile time:
https://llvm-compile-time-tracker.com/compare.php?from=ad28ff71647503c0a93f8b23a04844484f26f52b&to=c159423d2c3146b4c00fd00bd0d64ce802a74e03&stat=instructions

While i do expect this could be improved somewhat (1. pass instruction's current BB into findCommonDominator() and stop looping once CommonDom becomes that 2. ???),
i do think it's unresolvable in general, because why do we even perform this sinking in instcombine in the first place, does it allow some further instcombine folds?
We'll re-perform the same sinking each time we visit each instruction, that's a lot. If we'd just did it once, it would basically compile-time free.
Just thinking out loud.

Do we have to sink instruction in InstCombine?
Since InstCombine visits many instructions, it would be good to sink instructions outside of InstCombine.
Creating passes such as InstSink and calling them only once may also be a solution. How do you think?