Skip to content

Commit 253d691

Browse files
committed
[VPlan] Update VPBranchOnMaskRecipe to always set the mask (NFC).
The mask is always available at construction time. Make it non-optional to simlpify code.
1 parent 78c96aa commit 253d691

File tree

2 files changed

+4
-23
lines changed

2 files changed

+4
-23
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2503,10 +2503,7 @@ class VPReplicateRecipe : public VPRecipeWithIRFlags {
25032503
class VPBranchOnMaskRecipe : public VPRecipeBase {
25042504
public:
25052505
VPBranchOnMaskRecipe(VPValue *BlockInMask)
2506-
: VPRecipeBase(VPDef::VPBranchOnMaskSC, {}) {
2507-
if (BlockInMask) // nullptr means all-one mask.
2508-
addOperand(BlockInMask);
2509-
}
2506+
: VPRecipeBase(VPDef::VPBranchOnMaskSC, {BlockInMask}) {}
25102507

25112508
VPBranchOnMaskRecipe *clone() override {
25122509
return new VPBranchOnMaskRecipe(getOperand(0));
@@ -2527,21 +2524,10 @@ class VPBranchOnMaskRecipe : public VPRecipeBase {
25272524
void print(raw_ostream &O, const Twine &Indent,
25282525
VPSlotTracker &SlotTracker) const override {
25292526
O << Indent << "BRANCH-ON-MASK ";
2530-
if (VPValue *Mask = getMask())
2531-
Mask->printAsOperand(O, SlotTracker);
2532-
else
2533-
O << " All-One";
2527+
printOperands(O, SlotTracker);
25342528
}
25352529
#endif
25362530

2537-
/// Return the mask used by this recipe. Note that a full mask is represented
2538-
/// by a nullptr.
2539-
VPValue *getMask() const {
2540-
assert(getNumOperands() <= 1 && "should have either 0 or 1 operands");
2541-
// Mask is optional.
2542-
return getNumOperands() == 1 ? getOperand(0) : nullptr;
2543-
}
2544-
25452531
/// Returns true if the recipe uses scalars of operand \p Op.
25462532
bool usesScalars(const VPValue *Op) const override {
25472533
assert(is_contained(operands(), Op) &&

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,13 +2471,8 @@ void VPScalarCastRecipe ::print(raw_ostream &O, const Twine &Indent,
24712471
void VPBranchOnMaskRecipe::execute(VPTransformState &State) {
24722472
assert(State.Lane && "Branch on Mask works only on single instance.");
24732473

2474-
2475-
Value *ConditionBit = nullptr;
2476-
VPValue *BlockInMask = getMask();
2477-
if (BlockInMask)
2478-
ConditionBit = State.get(BlockInMask, *State.Lane);
2479-
else // Block in mask is all-one.
2480-
ConditionBit = State.Builder.getTrue();
2474+
VPValue *BlockInMask = getOperand(0);
2475+
Value *ConditionBit = State.get(BlockInMask, *State.Lane);
24812476

24822477
// Replace the temporary unreachable terminator with a new conditional branch,
24832478
// whose two destinations will be set later when they are created.

0 commit comments

Comments
 (0)