-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[VPlan] Support live-ins without underlying IR in type analysis. #80723
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 all commits
15b2c7c
7d88cd3
c49ca00
e5f9fec
7e9b7a1
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 |
---|---|---|
|
@@ -35,12 +35,7 @@ Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPInstruction *R) { | |
CachedTypes[OtherV] = ResTy; | ||
return ResTy; | ||
} | ||
case Instruction::ICmp: { | ||
// TODO: Check if types for both operands agree. This also requires | ||
// type-inference for the vector-trip-count, which is missing at the moment. | ||
Type *ResTy = inferScalarType(R->getOperand(0)); | ||
return ResTy; | ||
} | ||
case Instruction::ICmp: | ||
case VPInstruction::FirstOrderRecurrenceSplice: { | ||
Type *ResTy = inferScalarType(R->getOperand(0)); | ||
VPValue *OtherV = R->getOperand(1); | ||
|
@@ -207,8 +202,13 @@ Type *VPTypeAnalysis::inferScalarType(const VPValue *V) { | |
if (Type *CachedTy = CachedTypes.lookup(V)) | ||
return CachedTy; | ||
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. An alternative to caching the pre-computed type for all live-ins-w/o-underlying-value, as raised above, may be to change below into:
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. Updated as suggested, thanks! |
||
|
||
if (V->isLiveIn()) | ||
return V->getLiveInIRValue()->getType(); | ||
if (V->isLiveIn()) { | ||
if (auto *IRValue = V->getLiveInIRValue()) | ||
return IRValue->getType(); | ||
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. nit: worth a comment to explain who's expected to use CanonicalIVTy. 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. Added a comment ,thanks! |
||
// All VPValues without any underlying IR value (like the vector trip count | ||
// or the backedge-taken count) have the same type as the canonical IV. | ||
return CanonicalIVTy; | ||
} | ||
|
||
Type *ResultTy = | ||
TypeSwitch<const VPRecipeBase *, Type *>(V->getDefiningRecipe()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,10 @@ class Type; | |
/// of the previously inferred types. | ||
class VPTypeAnalysis { | ||
DenseMap<const VPValue *, Type *> CachedTypes; | ||
/// Type of the canonical induction variable. Used for all VPValues without | ||
/// any underlying IR value (like the vector trip count or the backedge-taken | ||
/// count). | ||
Type *CanonicalIVTy; | ||
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. nit: worth a comment what this is for. 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. added ,thanks! |
||
LLVMContext &Ctx; | ||
|
||
Type *inferScalarTypeForRecipe(const VPBlendRecipe *R); | ||
|
@@ -47,7 +51,8 @@ class VPTypeAnalysis { | |
Type *inferScalarTypeForRecipe(const VPReplicateRecipe *R); | ||
|
||
public: | ||
VPTypeAnalysis(LLVMContext &Ctx) : Ctx(Ctx) {} | ||
VPTypeAnalysis(Type *CanonicalIVTy, LLVMContext &Ctx) | ||
: CanonicalIVTy(CanonicalIVTy), Ctx(Ctx) {} | ||
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. nit (unrelated to this patch): does VPTypeAnalysis really need 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. We could retrieve the context from a type separately when needed. Can do separately if preferred? 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. Is there any current use of 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. The current uses are to create https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp#L63 |
||
|
||
/// Infer the type of \p V. Returns the scalar type of \p V. | ||
Type *inferScalarType(const VPValue *V); | ||
|
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.
nit: should have probably referred to
backedge-taken-count
, used by an ICmp to form the header mask, rather thanvector-trip-count
.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.
Yep.