-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[LoopVectorize] Add cost of generating tail-folding mask to the loop #130565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -801,6 +801,22 @@ InstructionCost VPInstruction::computeCost(ElementCount VF, | |
cast<VectorType>(VectorTy), Mask, | ||
Ctx.CostKind, VF.getKnownMinValue() - 1); | ||
} | ||
case VPInstruction::ActiveLaneMask: { | ||
Type *Arg0Ty = Ctx.Types.inferScalarType(getOperand(0)); | ||
Type *Arg1Ty = Ctx.Types.inferScalarType(getOperand(1)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. VPTypeAnalysis should already assert that both types are the same, so would probably be good to remove here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
Type *RetTy = toVectorTy(Type::getInt1Ty(Ctx.LLVMCtx), VF); | ||
IntrinsicCostAttributes Attrs(Intrinsic::get_active_lane_mask, RetTy, | ||
{Arg0Ty, Arg1Ty}); | ||
return Ctx.TTI.getIntrinsicInstrCost(Attrs, Ctx.CostKind); | ||
} | ||
case VPInstruction::ExplicitVectorLength: { | ||
Type *Arg0Ty = Ctx.Types.inferScalarType(getOperand(0)); | ||
Type *I32Ty = Type::getInt32Ty(Ctx.LLVMCtx); | ||
Type *I1Ty = Type::getInt1Ty(Ctx.LLVMCtx); | ||
IntrinsicCostAttributes Attrs(Intrinsic::experimental_get_vector_length, | ||
I32Ty, {Arg0Ty, I32Ty, I1Ty}); | ||
return Ctx.TTI.getIntrinsicInstrCost(Attrs, Ctx.CostKind); | ||
} | ||
default: | ||
// TODO: Compute cost other VPInstructions once the legacy cost model has | ||
// been retired. | ||
|
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if it would be cleaner to handle this in the caller of
expectedCost
, where we have the VPlans available. With that, we could just iterate over all recipes in the loop region and compute the costs for ActiveLaneMask/EVL using the VPlan-based cost model and add them to the cost returned byexpectedCost
?This might be more scalable for future use-cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough!