[InstCombine] Use canonical type in insertelement (NFC)
authorNikita Popov <npopov@redhat.com>
Wed, 17 May 2023 12:36:50 +0000 (14:36 +0200)
committerNikita Popov <npopov@redhat.com>
Wed, 17 May 2023 12:37:32 +0000 (14:37 +0200)
We can directly create these with the correct type.

llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp

index 3739497..231739d 100644 (file)
@@ -1542,7 +1542,7 @@ Value *InstCombinerImpl::SimplifyDemandedVectorElts(Value *V,
       // Found constant vector with single element - convert to insertelement.
       if (Op && Value) {
         Instruction *New = InsertElementInst::Create(
-            Op, Value, ConstantInt::get(Type::getInt32Ty(I->getContext()), Idx),
+            Op, Value, ConstantInt::get(Type::getInt64Ty(I->getContext()), Idx),
             Shuffle->getName());
         InsertNewInstWith(New, *Shuffle);
         return New;
index 4bab964..f077f6f 100644 (file)
@@ -1249,9 +1249,9 @@ static Instruction *foldInsSequenceIntoSplat(InsertElementInst &InsElt) {
       return nullptr;
 
   // Create the insert + shuffle.
-  Type *Int32Ty = Type::getInt32Ty(InsElt.getContext());
+  Type *Int64Ty = Type::getInt32Ty(InsElt.getContext());
   PoisonValue *PoisonVec = PoisonValue::get(VecTy);
-  Constant *Zero = ConstantInt::get(Int32Ty, 0);
+  Constant *Zero = ConstantInt::get(Int64Ty, 0);
   if (!cast<ConstantInt>(FirstIE->getOperand(2))->isZero())
     FirstIE = InsertElementInst::Create(PoisonVec, SplatVal, Zero, "", &InsElt);