[VectorCombine] Avoid ConstantExpr::get() (NFC)
authorNikita Popov <npopov@redhat.com>
Wed, 29 Jun 2022 15:17:20 +0000 (17:17 +0200)
committerNikita Popov <npopov@redhat.com>
Wed, 29 Jun 2022 15:17:52 +0000 (17:17 +0200)
Use IRBuilder APIs instead, which will still constant fold.

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

index 94c690a..9059893 100644 (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;