[llvm] [VectorCombine] Precisely calculate the cost in foldInstExtBinop and avoid infinite loop (PR #153069)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 15 02:28:37 PDT 2025
================
@@ -1250,6 +1256,10 @@ bool VectorCombine::scalarizeOpOrCmp(Instruction &I) {
InstructionCost NewCost =
ScalarOpCost + TTI.getVectorInstrCost(Instruction::InsertElement, VecTy,
CostKind, *Index, NewVecC);
+ // Additional cost for unfoldable constant expression.
+ if (!NewVecC)
+ NewCost += VectorOpCost;
+
----------------
XChy wrote:
Or `ConstantFoldInstOperands` may be simpler.
https://github.com/llvm/llvm-project/pull/153069
More information about the llvm-commits
mailing list