[llvm] 357a002 - [InstCombine] Remove old add in foldLShrOverflowBit()

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 1 06:30:33 PDT 2023


Author: Nikita Popov
Date: 2023-06-01T15:30:24+02:00
New Revision: 357a002c7c85c8cee41838fd5273bcb7d9334df7

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

LOG: [InstCombine] Remove old add in foldLShrOverflowBit()

Explicitly remove the old add instruction, so we don't need a
separate InstCombine iteration to DCE it.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
index 6f69e123014c2..89dad455f0151 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
@@ -919,8 +919,10 @@ Instruction *InstCombinerImpl::foldLShrOverflowBit(BinaryOperator &I) {
   // Replace the uses of the original add with a zext of the
   // NarrowAdd's result. Note that all users at this stage are known to
   // be ShAmt-sized truncs, or the lshr itself.
-  if (!Add->hasOneUse())
+  if (!Add->hasOneUse()) {
     replaceInstUsesWith(*AddInst, Builder.CreateZExt(NarrowAdd, Ty));
+    eraseInstFromFunction(*AddInst);
+  }
 
   // Replace the LShr with a zext of the overflow check.
   return new ZExtInst(Overflow, Ty);


        


More information about the llvm-commits mailing list