[llvm] [SLP]: Introduce and use getDataFlowCost (PR #112999)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 21 15:35:36 PDT 2024
================
@@ -10241,6 +10254,27 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
InstructionCost C = getEntryCost(&TE, VectorizedVals, CheckedExtracts);
Cost += C;
+
+ // Calculate the cost difference of propagating a vector vs series of scalars
+ // across blocks. This may be nonzero in the case of illegal vectors.
+ Instruction *VL0 = TE.getMainOp();
+ if (VL0 && ((I + 1) < VectorizableTree.size())) {
+ Instruction *VL1 = VectorizableTree[I + 1]->getMainOp();
+ if (VL1 && (VL0->getParent() != VL1->getParent())) {
+ Type *ScalarTy = VL0->getType()->getScalarType();
+ if (ScalarTy && isValidElementType(ScalarTy)) {
+ InstructionCost ScalarDFlow =
+ TTI->getDataFlowCost(ScalarTy,
+ /*IsCallingConv=*/false) *
+ TE.getVectorFactor();
+ InstructionCost VectorDFlow = TTI->getDataFlowCost(
+ FixedVectorType::get(ScalarTy, TE.getVectorFactor()),
+ /*IsCallingConv=*/false);
+ Cost += (VectorDFlow - ScalarDFlow);
+ }
+ }
+ }
+
----------------
alexey-bataev wrote:
1. It should not be here, it should be implemented in getEntryCost.
2. `vectorizableTree[I + 1]` does not always point to the operand of the previous node
https://github.com/llvm/llvm-project/pull/112999
More information about the llvm-commits
mailing list