[llvm] [VectorCombine] Scalarize bin ops and cmps with two splatted operands (PR #137786)
Min-Yih Hsu via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 29 10:07:35 PDT 2025
================
@@ -1134,12 +1149,16 @@ bool VectorCombine::scalarizeBinopOrCmp(Instruction &I) {
if (auto *ScalarInst = dyn_cast<Instruction>(Scalar))
ScalarInst->copyIRFlags(&I);
- // Fold the vector constants in the original vectors into a new base vector.
- 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);
+ Value *Result;
+ if (Index) {
+ // Fold the vector constants in the original vectors into a new base vector.
+ Value *NewVecC = IsCmp ? Builder.CreateCmp(Pred, VecC0, VecC1)
+ : Builder.CreateBinOp((Instruction::BinaryOps)Opcode,
+ VecC0, VecC1);
+ Result = Builder.CreateInsertElement(NewVecC, Scalar, *Index);
+ } else
----------------
mshockwave wrote:
matching curly braces
https://github.com/llvm/llvm-project/pull/137786
More information about the llvm-commits
mailing list