This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Reassociate add sequences to reduce dependency chains
AbandonedPublic

Authored by Chenbing.Zheng on May 7 2022, 2:13 AM.

Details

Summary

Reassociate add sequences to reduce dependency chains:
((A + B) + C) + D --> (A + B) + (C + D)

Diff Detail

Event Timeline

Chenbing.Zheng created this revision.May 7 2022, 2:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 7 2022, 2:13 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
Chenbing.Zheng requested review of this revision.May 7 2022, 2:13 AM
spatel added a comment.May 7 2022, 5:31 AM

What is the motivating case for this canonicalization? This requires more justification than the usual instcombine transform because it is the inverse of what another canonicalization pass (-reassociate) would do.

Note that we do have this transform in the backend with "MachineCombiner", so it should handle cases like the ones shown in the test diffs if that is profitable.

spatel added a comment.May 7 2022, 5:48 AM

https://reviews.llvm.org/D67383 is more general solution, no?

Yes, that's definitely a bigger/better solution for the likely real-world problems. That patch stalled, but I don't think there were any real objections to adding a pass like that.

Chenbing.Zheng abandoned this revision.May 8 2022, 7:59 PM

What is the motivating case for this canonicalization? This requires more justification than the usual instcombine transform because it is the inverse of what another canonicalization pass (-reassociate) would do.

Note that we do have this transform in the backend with "MachineCombiner", so it should handle cases like the ones shown in the test diffs if that is profitable.

At first I wanted to solve this problem D125198. I think It is friendly to instruction parallelism, so I went to do this transformation by the way.
Do this transform in the backend with "MachineCombiner" is more reasonable.