Reassociate add sequences to reduce dependency chains:
((A + B) + C) + D --> (A + B) + (C + D)
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
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.
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.
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.