This is an archive of the discontinued LLVM Phabricator instance.

[Canonicalize] Don't call isBeforeInBlock in OperationFolder::tryToFold.
ClosedPublic

Authored by lattner on Sep 8 2021, 10:28 AM.

Details

Summary

This patch (e4635e6328c8) fixed a bug where a newly generated/reused
constant wouldn't dominate a folded operation. It did so by calling
isBeforeInBlock to move the constant around on demand. This introduced
a significant compile time regression, because "isBeforeInBlock" is
O(n) in the size of a block the first time it is called, and the cache
is invalidated any time canonicalize changes something big in the block.

This fixes LLVM PR51738 and this CIRCT issue:
https://github.com/llvm/circt/issues/1700

This does affect the order of constants left in the top of a block,
I staged in the testsuite changes in rG42431b8207a5.

Diff Detail

Event Timeline

lattner created this revision.Sep 8 2021, 10:28 AM
lattner requested review of this revision.Sep 8 2021, 10:28 AM

River, I think this is what you were asking for?

This revision was not accepted when it landed; it landed in state Needs Review.Sep 8 2021, 1:33 PM
This revision was automatically updated to reflect the committed changes.

I was let know off-line that River is out for a week. Given this is basically the patch he prescribes in PR51738, I consider this to be obvious.

Thanks for the confirmation River!