[InstCombine] Remove unnecessary type equality check when creating zext or trunc (NFC)#175947
Merged
antoniofrighetto merged 1 commit intollvm:mainfrom Jan 14, 2026
Conversation
Member
|
@llvm/pr-subscribers-llvm-transforms Author: Gábor Spaits (spaits) ChangesThis came up during discussions under PR #161101. Full diff: https://github.com/llvm/llvm-project/pull/175947.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 4c70e4a6e0fe0..eee3d0f6f3e1d 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -3965,8 +3965,7 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
Value *V = Builder.CreateBitCast(
Vect, Builder.getIntNTy(FTy->getNumElements()));
Value *Res = Builder.CreateUnaryIntrinsic(Intrinsic::ctpop, V);
- if (Res->getType() != II->getType())
- Res = Builder.CreateZExtOrTrunc(Res, II->getType());
+ Res = Builder.CreateZExtOrTrunc(Res, II->getType());
if (Arg != Vect &&
cast<Instruction>(Arg)->getOpcode() == Instruction::SExt)
Res = Builder.CreateNeg(Res);
@@ -4041,8 +4040,7 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
if (auto *VTy = dyn_cast<VectorType>(Vect->getType()))
if (VTy->getElementType() == Builder.getInt1Ty()) {
Value *Res = Builder.CreateAndReduce(Vect);
- if (Res->getType() != II->getType())
- Res = Builder.CreateZExt(Res, II->getType());
+ Res = Builder.CreateZExt(Res, II->getType());
return replaceInstUsesWith(CI, Res);
}
}
|
nikic
approved these changes
Jan 14, 2026
Priyanshu3820
pushed a commit
to Priyanshu3820/llvm-project
that referenced
this pull request
Jan 18, 2026
…xt or trunc (NFC) (llvm#175947) This came up during discussions under PR llvm#161101.
BStott6
pushed a commit
to BStott6/llvm-project
that referenced
this pull request
Jan 22, 2026
…xt or trunc (NFC) (llvm#175947) This came up during discussions under PR llvm#161101.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This came up during discussions under PR #161101.