[VectorCombine] Avoid ConstantExpr::get() (NFC)

Use IRBuilder APIs instead, which will still constant fold.
This commit is contained in:
Nikita Popov 2022-06-29 17:17:20 +02:00
parent 98007e9753
commit bdba8278d9
1 changed files with 3 additions and 2 deletions

View File

@ -697,8 +697,9 @@ bool VectorCombine::scalarizeBinopOrCmp(Instruction &I) {
ScalarInst->copyIRFlags(&I);
// Fold the vector constants in the original vectors into a new base vector.
Constant *NewVecC = IsCmp ? ConstantExpr::getCompare(Pred, VecC0, VecC1)
: ConstantExpr::get(Opcode, VecC0, VecC1);
Value *NewVecC =
IsCmp ? Builder.CreateCmp(Pred, VecC0, VecC1)
: Builder.CreateBinOp((Instruction::BinaryOps)Opcode, VecC0, VecC1);
Value *Insert = Builder.CreateInsertElement(NewVecC, Scalar, Index);
replaceValue(I, *Insert);
return true;