[llvm] [SeparateConstOffsetFromGEP] - Fix the simplification of GEP index when its operand is an XOR constant. (PR #175724)
Pawan Nirpal via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 29 06:04:46 PST 2026
pawan-nirpal-031 wrote:
@nikic Thanks for the elaborate comment! I experimented on your suggestions.
Two things came up.
1) "should not push to UserChain in extractDisjointBitsFromXor" The thing is distributeCastsAndCloneChain() expects a constant at the end of the chain, breaking that invariant means doing a major refactor of this pass from my vantage point, also It's not clear to me how that would work. So I'm trying to be conservative about the fix, overall the pass itself seems overly complex in design and lapses in correctness seem all over the place.
```
if (ChainIndex == 0) {
assert(isa<ConstantInt>(U));
// If U is a ConstantInt, applyCasts will return a ConstantInt as well.
return UserChain[ChainIndex] = cast<ConstantInt>(applyCasts(U));
}
````
2) ``` unsigned OpNo = (BO->getOperand(0) == UserChain[ChainIndex - 1] ? 0 : 1); ``` we can make this much more explicit and choose OpNo based on non-constant operand of the BO but we may still run into BO's that have both operands as constants, in which case it's ambiguous what has to be done ( fall back to this comparison for a start maybe? )
https://github.com/llvm/llvm-project/pull/175724
More information about the llvm-commits
mailing list