Skip to content

Commit 6076667

Browse files
committed
[InstCombine] Use canonical index type (NFC)
Directly use the canonical index type, rather than canonicalizing it afterwards.
1 parent 3ffd13b commit 6076667

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ static APInt findDemandedEltsByAllUsers(Value *V) {
384384
/// return it with the canonical type if it isn't already canonical. We
385385
/// arbitrarily pick 64 bit as our canonical type. The actual bitwidth doesn't
386386
/// matter, we just want a consistent type to simplify CSE.
387-
ConstantInt *getPreferredVectorIndex(ConstantInt *IndexC) {
387+
static ConstantInt *getPreferredVectorIndex(ConstantInt *IndexC) {
388388
const unsigned IndexBW = IndexC->getType()->getBitWidth();
389389
if (IndexBW == 64 || IndexC->getValue().getActiveBits() > 64)
390390
return nullptr;
@@ -2183,8 +2183,7 @@ static Instruction *canonicalizeInsertSplat(ShuffleVectorInst &Shuf,
21832183

21842184
// Insert into element 0 of an undef vector.
21852185
UndefValue *UndefVec = UndefValue::get(Shuf.getType());
2186-
Constant *Zero = Builder.getInt32(0);
2187-
Value *NewIns = Builder.CreateInsertElement(UndefVec, X, Zero);
2186+
Value *NewIns = Builder.CreateInsertElement(UndefVec, X, (uint64_t)0);
21882187

21892188
// Splat from element 0. Any mask element that is undefined remains undefined.
21902189
// For example:
@@ -2779,7 +2778,6 @@ Instruction *InstCombinerImpl::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
27792778
}
27802779

27812780
ArrayRef<int> Mask = SVI.getShuffleMask();
2782-
Type *Int32Ty = Type::getInt32Ty(SVI.getContext());
27832781

27842782
// Peek through a bitcasted shuffle operand by scaling the mask. If the
27852783
// simulated shuffle can simplify, then this shuffle is unnecessary:
@@ -2943,8 +2941,8 @@ Instruction *InstCombinerImpl::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
29432941
: Builder.CreateBitCast(V, CastSrcTy, SVI.getName() + ".bc");
29442942
if (!BCAlreadyExists)
29452943
NewBCs[CastSrcTy] = NewBC;
2946-
auto *Ext = Builder.CreateExtractElement(
2947-
NewBC, ConstantInt::get(Int32Ty, BegIdx), SVI.getName() + ".extract");
2944+
auto *Ext = Builder.CreateExtractElement(NewBC, BegIdx,
2945+
SVI.getName() + ".extract");
29482946
// The shufflevector isn't being replaced: the bitcast that used it
29492947
// is. InstCombine will visit the newly-created instructions.
29502948
replaceInstUsesWith(*BC, Ext);

0 commit comments

Comments
 (0)