Skip to content

Commit 4cbad66

Browse files
committed
Emit VPWidenIntrinsicRecipe
1 parent 817d761 commit 4cbad66

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,21 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags {
16921692
MayWriteToMemory(MayWriteToMemory),
16931693
MayHaveSideEffects(MayHaveSideEffects) {}
16941694

1695+
VPWidenIntrinsicRecipe(Intrinsic::ID VectorIntrinsicID,
1696+
std::initializer_list<VPValue *> CallArguments,
1697+
Type *Ty, DebugLoc DL = {})
1698+
: VPRecipeWithIRFlags(VPDef::VPWidenIntrinsicSC, CallArguments),
1699+
VectorIntrinsicID(VectorIntrinsicID), ResultTy(Ty) {
1700+
LLVMContext &Ctx = Ty->getContext();
1701+
AttributeList Attrs = Intrinsic::getAttributes(Ctx, VectorIntrinsicID);
1702+
MemoryEffects ME = Attrs.getMemoryEffects();
1703+
MayReadFromMemory = ME.onlyWritesMemory();
1704+
MayWriteToMemory = ME.onlyReadsMemory();
1705+
MayHaveSideEffects = MayWriteToMemory ||
1706+
Attrs.hasFnAttr(Attribute::NoUnwind) ||
1707+
!Attrs.hasFnAttr(Attribute::WillReturn);
1708+
}
1709+
16951710
~VPWidenIntrinsicRecipe() override = default;
16961711

16971712
VPWidenIntrinsicRecipe *clone() override {

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,9 @@ void VPlanTransforms::addActiveLaneMask(
13531353
/// Replace recipes with their EVL variants.
13541354
static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
13551355
using namespace llvm::VPlanPatternMatch;
1356-
LLVMContext &Ctx = Plan.getCanonicalIV()->getScalarType()->getContext();
1356+
Type *CanonicalIVType = Plan.getCanonicalIV()->getScalarType();
1357+
VPTypeAnalysis TypeInfo(CanonicalIVType);
1358+
LLVMContext &Ctx = CanonicalIVType->getContext();
13571359
SmallVector<VPValue *> HeaderMasks = collectAllHeaderMasks(Plan);
13581360
VPTypeAnalysis TypeInfo(Plan.getCanonicalIV()->getScalarType());
13591361
for (VPValue *HeaderMask : collectAllHeaderMasks(Plan)) {
@@ -1403,9 +1405,9 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
14031405
// limited to selects whose condition is a header mask.
14041406
VPValue *AllTrue =
14051407
Plan.getOrAddLiveIn(ConstantInt::getTrue(Ctx));
1406-
return new VPInstruction(VPInstruction::MergeUntilPivot,
1407-
{AllTrue, LHS, RHS, &EVL},
1408-
VPI->getDebugLoc());
1408+
return new VPWidenIntrinsicRecipe(
1409+
Intrinsic::vp_merge, {AllTrue, LHS, RHS, &EVL},
1410+
TypeInfo.inferScalarType(LHS), VPI->getDebugLoc());
14091411
})
14101412
.Default([&](VPRecipeBase *R) { return nullptr; });
14111413

0 commit comments

Comments
 (0)