[llvm] [Value] Look through inttoptr (add ..) in accumulateConstantOffsets (PR #124981)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 30 10:43:04 PST 2025


================
@@ -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);
----------------
fhahn wrote:

Done thanks

https://github.com/llvm/llvm-project/pull/124981


More information about the llvm-commits mailing list