[llvm] d09632b - [InstCombine] Remove nusw handling in ptrtoint of gep fold (NFCI) (#118804)

via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 5 06:59:39 PST 2024


Author: Nikita Popov
Date: 2024-12-05T15:59:35+01:00
New Revision: d09632ba819d21b12cdf0ec107209c0c5cbf100d

URL: https://github.com/llvm/llvm-project/commit/d09632ba819d21b12cdf0ec107209c0c5cbf100d
DIFF: https://github.com/llvm/llvm-project/commit/d09632ba819d21b12cdf0ec107209c0c5cbf100d.diff

LOG: [InstCombine] Remove nusw handling in ptrtoint of gep fold (NFCI) (#118804)

Now that #111144 infers gep nuw, we no longer have to repeat the
inference in this fold.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 7221c987b98219..d21714b10155d9 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -2106,10 +2106,7 @@ Instruction *InstCombinerImpl::visitPtrToInt(PtrToIntInst &CI) {
         Base->getType() == Ty) {
       Value *Offset = EmitGEPOffset(GEP);
       auto *NewOp = BinaryOperator::CreateAdd(Base, Offset);
-      if (GEP->hasNoUnsignedWrap() ||
-          (GEP->hasNoUnsignedSignedWrap() &&
-           isKnownNonNegative(Offset, SQ.getWithInstruction(&CI))))
-        NewOp->setHasNoUnsignedWrap(true);
+      NewOp->setHasNoUnsignedWrap(GEP->hasNoUnsignedWrap());
       return NewOp;
     }
   }


        


More information about the llvm-commits mailing list