This was only using the SCEV expressions as a map key, which we can
do just as well with the value pointers.
Details
Diff Detail
Event Timeline
llvm/test/Transforms/SeparateConstOffsetFromGEP/AArch64/split-gep.ll | ||
---|---|---|
1 ↗ | (On Diff #529629) | -verify-scev is on in expensive builds so I don't think it's necessary to add it to many tests. maybe we should turn on the other two as well in expensive builds? |
llvm/test/Transforms/SeparateConstOffsetFromGEP/AArch64/split-gep.ll | ||
---|---|---|
1 ↗ | (On Diff #529629) | Currently can't turn them on because there are a lot of failures: https://github.com/llvm/llvm-project/issues/63195 |
llvm/test/Transforms/SeparateConstOffsetFromGEP/AArch64/split-gep.ll | ||
---|---|---|
1 ↗ | (On Diff #529629) | Please do not use any SCEV verification flags other than -verify-scev. |
I think this is okay, but I just took a look at what this pass actually does with SCEV and ... wat.
As far as I can tell, SCEV here can be replaced by using a std::pair<Value *, Value *> instead of a SCEV expressions in the DominatingAdd/DominatingSub maps. Might be better to do that and not request SCEV at all?
Went to describe the issue in the ticket and ended up with the patch which seems to work
llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp | ||
---|---|---|
1235 | I believe the previous code would also detect cases where the add operands are swapped as the same. Could add something like static std::pair<Value *, Value *> createNormalizedPair(Value *A, Value *B) { if (A < B) return {A, B}; return {B, A}; } and use it for the add case to preserve that behavior. Though the fact that it's apparently untested is not reassuring... |
llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp | ||
---|---|---|
1235 | Most the code in the pass has sparse testing. I've rebased on a new test which showed this broke | |
1262 | Wasn't sure about trying to preserve this behavior. Seems like it would only fire for constant cases, where you would expect the extension of constant to fold to a larger constant which wasn't pattern matched before |
LGTM
Nice to see that this also adds vector support as a side effect.
llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp | ||
---|---|---|
1262 | This doesn't constant fold either due to use of SCEVUnknown. The reason for the getNegativeSCEV call here is to prevent the commutation behavior for subs. In your new implementation it's no longer needed. |
I believe the previous code would also detect cases where the add operands are swapped as the same. Could add something like
and use it for the add case to preserve that behavior. Though the fact that it's apparently untested is not reassuring...