Skip to content

Commit 901297f

Browse files
committed
Remove outer-loop comment and re-design getVFScaleFactor interface
1 parent 9130747 commit 901297f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2678,7 +2678,6 @@ class LLVM_ABI_FOR_TEST VPReductionRecipe : public VPRecipeWithIRFlags {
26782678
bool IsConditional = false;
26792679
/// The scaling factor, relative to the VF, that this recipe's output is
26802680
/// divided by.
2681-
/// For outer-loop reductions this is equal to 1.
26822681
/// For in-loop reductions this is equal to 0, to specify that this is equal
26832682
/// to the VF (which may not be known yet).
26842683
/// For partial-reductions this is equal to another scalar value.
@@ -2763,8 +2762,11 @@ class LLVM_ABI_FOR_TEST VPReductionRecipe : public VPRecipeWithIRFlags {
27632762
VPValue *getCondOp() const {
27642763
return isConditional() ? getOperand(getNumOperands() - 1) : nullptr;
27652764
}
2766-
/// Get the factor that the VF of this recipe's output should be scaled by.
2767-
unsigned getVFScaleFactor() const { return VFScaleFactor; }
2765+
/// Get the factor that the VF of this recipe's output should be scaled by, or
2766+
/// null if it isn't scaled.
2767+
std::optional<unsigned> getVFScaleFactor() const {
2768+
return VFScaleFactor > 1 ? std::make_optional(VFScaleFactor) : std::nullopt;
2769+
}
27682770
};
27692771

27702772
/// A recipe to represent inloop reduction operations with vector-predication

llvm/lib/Transforms/Vectorize/VPlanUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ unsigned vputils::getVFScaleFactor(VPRecipeBase *R) {
146146
if (auto *RR = dyn_cast<VPReductionPHIRecipe>(R))
147147
return RR->getVFScaleFactor();
148148
if (auto *RR = dyn_cast<VPReductionRecipe>(R))
149-
return RR->getVFScaleFactor();
149+
return RR->getVFScaleFactor().value_or(1);
150150
assert(
151151
(!isa<VPInstruction>(R) || cast<VPInstruction>(R)->getOpcode() !=
152152
VPInstruction::ReductionStartVector) &&

0 commit comments

Comments
 (0)