[llvm] [EarlyCSE] Compare GEP instructions based on offset (PR #65875)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 19 03:33:24 PDT 2023
================
@@ -1561,6 +1646,31 @@ bool EarlyCSE::processNode(DomTreeNode *Node) {
continue;
}
+ // Compare GEP instructions based on offset.
+ if (GEPValue::canHandle(&Inst)) {
+ auto *GEP = cast<GetElementPtrInst>(&Inst);
+ APInt Offset = APInt(SQ.DL.getIndexTypeSizeInBits(GEP->getType()), 0);
+ GEPValue GEPVal(GEP, GEP->accumulateConstantOffset(SQ.DL, Offset)
+ ? Offset.tryZExtValue()
----------------
nikic wrote:
I think the offset should be `int64_t` and use `trySExtValue()` here. GEP offsets are signed. (Mainly for clarify, I think it will not make a functional difference?)
https://github.com/llvm/llvm-project/pull/65875
More information about the llvm-commits
mailing list