Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion llvm/lib/Transforms/Vectorize/VPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -2711,7 +2711,13 @@ class LLVM_ABI_FOR_TEST VPWidenPHIRecipe : public VPSingleDefRecipe,
: VPSingleDefRecipe(VPRecipeBase::VPWidenPHISC, IncomingValues,
getScalarTypeOrInfer(IncomingValues[0]),
/*UV=*/nullptr, DL),
Name(Name.str()) {}
Name(Name.str()) {
assert(all_of(IncomingValues,
[this](VPValue *VPV) {
return VPV->getScalarType() == getScalarType();
}) &&
"all incoming values must have the same type");
}

VPWidenPHIRecipe *clone() override {
return new VPWidenPHIRecipe(operands(), getDebugLoc(), Name);
Expand Down Expand Up @@ -2912,6 +2918,17 @@ class LLVM_ABI_FOR_TEST VPBlendRecipe : public VPRecipeWithIRFlags {
: VPRecipeWithIRFlags(VPRecipeBase::VPBlendSC, Operands,
Operands[0]->getScalarType(), Flags, DL) {
assert(Operands.size() >= 2 && "Expected at least two operands!");
assert(all_of(seq<unsigned>(0, getNumIncomingValues()),
[this](unsigned I) {
return getIncomingValue(I)->getScalarType() ==
getScalarType();
}) &&
"all incoming values must have the same type");
assert(all_of(seq<unsigned>(isNormalized(), getNumIncomingValues()),
[this](unsigned I) {
return getMask(I)->getScalarType()->isIntegerTy(1);
}) &&
"masks must be a bool");
setUnderlyingValue(Phi);
}

Expand Down Expand Up @@ -3181,7 +3198,17 @@ class LLVM_ABI_FOR_TEST VPReductionRecipe : public VPRecipeWithIRFlags {
: VPRecipeWithIRFlags(SC, Operands, Operands[0]->getScalarType(), FMFs,
DL),
RdxKind(RdxKind), Style(Style) {
assert(all_of(Operands,
[this](VPValue *VPV) {
return VPV->getScalarType() == getScalarType() ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because the EVL can be an operand in a FP reduction right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it gets added as operand for VPReductionEVLRecipe

(isa<VPInstruction>(VPV) &&
cast<VPInstruction>(VPV)->getOpcode() ==
VPInstruction::ExplicitVectorLength);
Comment thread
lukel97 marked this conversation as resolved.
}) &&
"all incoming values must have the same type");
if (CondOp) {
assert(CondOp->getScalarType()->isIntegerTy(1) &&
"CondOp must be a bool");
IsConditional = true;
addOperand(CondOp);
}
Expand Down
10 changes: 5 additions & 5 deletions llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ TEST_F(VPRecipeTest, CastVPBlendRecipeToVPUser) {

VPValue *I1 = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 1));
VPValue *I2 = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 2));
VPValue *M2 = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 3));
VPValue *M2 = Plan.getOrAddLiveIn(ConstantInt::getTrue(C));
SmallVector<VPValue *, 4> Args;
Args.push_back(I1);
Args.push_back(I2);
Expand Down Expand Up @@ -1397,7 +1397,7 @@ TEST_F(VPRecipeTest, MayHaveSideEffectsAndMayReadWriteMemory) {
{
VPValue *ChainOp = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 1));
VPValue *VecOp = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 2));
VPValue *CondOp = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 3));
VPValue *CondOp = Plan.getOrAddLiveIn(ConstantInt::getTrue(C));
VPReductionRecipe Recipe(RecurKind::Add, FastMathFlags(), ChainOp, VecOp,
CondOp, RdxUnordered{});
EXPECT_FALSE(Recipe.mayHaveSideEffects());
Expand All @@ -1409,7 +1409,7 @@ TEST_F(VPRecipeTest, MayHaveSideEffectsAndMayReadWriteMemory) {
{
VPValue *ChainOp = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 1));
VPValue *VecOp = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 2));
VPValue *CondOp = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 3));
VPValue *CondOp = Plan.getOrAddLiveIn(ConstantInt::getTrue(C));
VPReductionRecipe Recipe(RecurKind::Add, FastMathFlags(), ChainOp, VecOp,
CondOp, RdxUnordered{});
VPValue *EVL = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 4));
Expand Down Expand Up @@ -1741,7 +1741,7 @@ TEST_F(VPRecipeTest, CastVPReductionRecipeToVPUser) {
IntegerType *Int32 = IntegerType::get(C, 32);
VPValue *ChainOp = getPlan().getOrAddLiveIn(ConstantInt::get(Int32, 1));
VPValue *VecOp = getPlan().getOrAddLiveIn(ConstantInt::get(Int32, 2));
VPValue *CondOp = getPlan().getOrAddLiveIn(ConstantInt::get(Int32, 3));
VPValue *CondOp = getPlan().getOrAddLiveIn(ConstantInt::getTrue(C));
VPReductionRecipe Recipe(RecurKind::Add, FastMathFlags(), ChainOp, VecOp,
CondOp, RdxUnordered{});
checkVPRecipeCastImpl<VPReductionRecipe, VPUser>(&Recipe);
Expand All @@ -1754,7 +1754,7 @@ TEST_F(VPRecipeTest, CastVPReductionEVLRecipeToVPUser) {
IntegerType *Int32 = IntegerType::get(C, 32);
VPValue *ChainOp = getPlan().getOrAddLiveIn(ConstantInt::get(Int32, 1));
VPValue *VecOp = getPlan().getOrAddLiveIn(ConstantInt::get(Int32, 2));
VPValue *CondOp = getPlan().getOrAddLiveIn(ConstantInt::get(Int32, 3));
VPValue *CondOp = getPlan().getOrAddLiveIn(ConstantInt::getTrue(C));
VPReductionRecipe Recipe(RecurKind::Add, FastMathFlags(), ChainOp, VecOp,
CondOp, RdxUnordered{});
VPValue *EVL = getPlan().getOrAddLiveIn(ConstantInt::get(Int32, 0));
Expand Down
Loading