[llvm] bdcf208 - Recommit "[InstCombine] Retain exact instruction name for some cases in SimplifyDemandedUseBits."

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 2 20:58:56 PST 2023


Author: Craig Topper
Date: 2023-12-02T20:53:34-08:00
New Revision: bdcf2087d9fb6112cc5a367590a633796af83015

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

LOG: Recommit "[InstCombine] Retain exact instruction name for some cases in SimplifyDemandedUseBits."

It looks like my original patch got caught up in
ef388334ee5a3584255b9ef5b3fefdb244fa3fd7 that was reverting a different
patch.

Original message:
Retain name for SExt->ZExt and AShr->LShr. Previously SExt->ZExt copied
the name with a numeric suffix. AShr->LShr dropped it.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index df65b83f2f06c..f2e40e77ab497 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -476,7 +476,8 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
     if (InputKnown.isNonNegative() ||
         DemandedMask.getActiveBits() <= SrcBitWidth) {
       // Convert to ZExt cast.
-      CastInst *NewCast = new ZExtInst(I->getOperand(0), VTy, I->getName());
+      CastInst *NewCast = new ZExtInst(I->getOperand(0), VTy);
+      NewCast->takeName(I);
       return InsertNewInstWith(NewCast, I->getIterator());
      }
 
@@ -784,6 +785,7 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
         BinaryOperator *LShr = BinaryOperator::CreateLShr(I->getOperand(0),
                                                           I->getOperand(1));
         LShr->setIsExact(cast<BinaryOperator>(I)->isExact());
+        LShr->takeName(I);
         return InsertNewInstWith(LShr, I->getIterator());
       } else if (Known.One[BitWidth-ShiftAmt-1]) { // New bits are known one.
         Known.One |= HighBits;


        


More information about the llvm-commits mailing list