[llvm] [SCEV] Handle more adds in computeConstantDifference() (PR #101339)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 1 15:10:23 PDT 2024


https://github.com/preames approved this pull request.

LGTM.  Nice!

A couple of thoughts for follow on changes:
1) I think you can handle mul -1, X by inverting multiplicity.  Could possibly handle other mul-by-constants too.
2) Once you did that, could we generalize this slightly to fold getMinusSCEV construction before resorting to the full add case?  That wouldn't be all zero multiplicities, but would return the operands and their multiplicity.  

Actually, it looks like we have something like this in CollectAddOperandsWithScales, common/share?



https://github.com/llvm/llvm-project/pull/101339


More information about the llvm-commits mailing list