[llvm] [EarlyCSE] Compare GEP instructions based on offset (PR #65875)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 14 01:51:46 PDT 2023
================
@@ -336,6 +336,13 @@ static unsigned getHashValueImpl(SimpleValue Val) {
if (CallInst *CI = dyn_cast<CallInst>(Inst))
return hashCallInst(CI);
+ if (auto *GEP = dyn_cast<GetElementPtrInst>(Inst)) {
+ auto &DL = GEP->getModule()->getDataLayout();
+ APInt Offset(DL.getIndexTypeSizeInBits(GEP->getType()), 0);
+ if (GEP->accumulateConstantOffset(DL, Offset))
+ return hash_combine(GEP->getOpcode(), GEP->getOperand(0), Offset);
----------------
nikic wrote:
nit: getPointerOperand().
https://github.com/llvm/llvm-project/pull/65875
More information about the llvm-commits
mailing list