[llvm] 7df92fb - [InstCombine] Remove redundant icmp gep fold (NFCI)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 25 01:31:10 PDT 2023


Author: Nikita Popov
Date: 2023-10-25T10:31:02+02:00
New Revision: 7df92fbe74e3c1b41c06f5fc784473f7f22aeed7

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

LOG: [InstCombine] Remove redundant icmp gep fold (NFCI)

Gep with zero indices will be folded away independently. It will
only be retained for splat geps, for which the transform is not
applicable anyway.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 5e16afa32e56beb..f39bfc655bf9cf5 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -3952,14 +3952,6 @@ Instruction *InstCombinerImpl::foldICmpInstWithConstantNotInt(ICmpInst &I) {
     return nullptr;
 
   switch (LHSI->getOpcode()) {
-  case Instruction::GetElementPtr:
-    // icmp pred GEP (P, int 0, int 0, int 0), null -> icmp pred P, null
-    if (RHSC->isNullValue() &&
-        cast<GetElementPtrInst>(LHSI)->hasAllZeroIndices())
-      return new ICmpInst(
-          I.getPredicate(), LHSI->getOperand(0),
-          Constant::getNullValue(LHSI->getOperand(0)->getType()));
-    break;
   case Instruction::PHI:
     if (Instruction *NV = foldOpIntoPhi(I, cast<PHINode>(LHSI)))
       return NV;


        


More information about the llvm-commits mailing list