[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 04:45:17 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:
`simplifyInstWithOperands` requires distinguishing intrinsics among the operators. Thus, I implement by `simplifyCmpInst`, `simplifyUnOp`, etc., case by case.
https://github.com/llvm/llvm-project/pull/153069
More information about the llvm-commits
mailing list