Skip to content

[InstCombine] Retain exact instruction name for some cases in SimplifyDemandedUseBits. #68371

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Oct 6, 2023

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

…yDemandedUseBits.

Retain name for SExt->ZExt and AShr->LShr. Previously SExt->ZExt copied the name
with a numeric suffix. AShr->LShr dropped it.
@topperc topperc requested a review from nikic as a code owner October 6, 2023 01:21
@topperc topperc changed the title [InstCombine] Retain exact instruction name for some cases in Simplif… [InstCombine] Retain exact instruction name for some cases in SimplifyDemandedUseBits. Oct 6, 2023
@llvmbot
Copy link
Member

llvmbot commented Oct 6, 2023

@llvm/pr-subscribers-llvm-transforms

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/68371.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp (+3-1)
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index abdaf167d3d9dfb..5b5d2da041f1447 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -461,7 +461,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());
      }
 
@@ -770,6 +771,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;

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@topperc topperc merged commit 98b114d into llvm:main Oct 6, 2023
@topperc topperc deleted the pr/instcombine-name branch November 1, 2023 01:23
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants