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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 5 05:50:08 PST 2024


https://github.com/nikic created https://github.com/llvm/llvm-project/pull/118804

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

>From 5fa65037ac7d65d439fc9c2c0434942273803ae0 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Thu, 5 Dec 2024 14:48:34 +0100
Subject: [PATCH] [InstCombine] Remove nusw handling in ptrtoint of gep fold

Now that #111144 infers gep nuw, we no longer have to repeat the
inference in this fold.
---
 llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

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