aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ConstantFolding.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r--llvm/lib/Analysis/ConstantFolding.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 80c1277..d645bf8 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -1258,11 +1258,16 @@ Constant *llvm::ConstantFoldCompareInstOperands(
if (Ops0->getType()->isPointerTy() && !ICmpInst::isSigned(Predicate)) {
unsigned IndexWidth = DL.getIndexTypeSizeInBits(Ops0->getType());
APInt Offset0(IndexWidth, 0);
- Value *Stripped0 =
- Ops0->stripAndAccumulateInBoundsConstantOffsets(DL, Offset0);
+ bool IsEqPred = ICmpInst::isEquality(Predicate);
+ Value *Stripped0 = Ops0->stripAndAccumulateConstantOffsets(
+ DL, Offset0, /*AllowNonInbounds=*/IsEqPred,
+ /*AllowInvariantGroup=*/false, /*ExternalAnalysis=*/nullptr,
+ /*LookThroughIntToPtr=*/IsEqPred);
APInt Offset1(IndexWidth, 0);
- Value *Stripped1 =
- Ops1->stripAndAccumulateInBoundsConstantOffsets(DL, Offset1);
+ Value *Stripped1 = Ops1->stripAndAccumulateConstantOffsets(
+ DL, Offset1, /*AllowNonInbounds=*/IsEqPred,
+ /*AllowInvariantGroup=*/false, /*ExternalAnalysis=*/nullptr,
+ /*LookThroughIntToPtr=*/IsEqPred);
if (Stripped0 == Stripped1)
return ConstantInt::getBool(
Ops0->getContext(),