From bdba8278d9c361103d32cfd56a215d017d444e9c Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 29 Jun 2022 17:17:20 +0200 Subject: [PATCH] [VectorCombine] Avoid ConstantExpr::get() (NFC) Use IRBuilder APIs instead, which will still constant fold. --- llvm/lib/Transforms/Vectorize/VectorCombine.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp index 94c690a..9059893 100644 --- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp +++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp @@ -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; -- 2.7.4