-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LV][EVL] Restore inbounds flag in VPVectorEndPointerRecipe when using EVL tail folding #145306
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -2171,6 +2171,29 @@ static VPRecipeBase *createEVLRecipe(VPValue *HeaderMask, | |
.Default([&](VPRecipeBase *R) { return nullptr; }); | ||
} | ||
|
||
// Replace VF operands with EVL in recipes that use VF. | ||
static void replaceVFWithEVL(VPValue &VF, VPValue &EVL) { | ||
for (VPUser *U : to_vector(VF.users())) { | ||
if (auto *VEP = dyn_cast<VPVectorEndPointerRecipe>(U)) { | ||
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. Early exit, if the condition is false, to reduce structure complexity? |
||
VPValue *Ptr = VEP->getPtr(); | ||
GEPNoWrapFlags NewFlags = VEP->getGEPNoWrapFlags(); | ||
// Replacing VF with EVL ensures that VPVectorEndPointer will not compute | ||
// out-of-bounds, as long as the original pointer had the inbounds flag. | ||
if (!NewFlags.isInBounds()) { | ||
if (auto *GEP = dyn_cast<GetElementPtrInst>( | ||
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 shouldn't rely on the the underlying GEP to re-set How critical is this? If it is important would be good to think of a better way to preserve the inbounds until EVL recipes are added or recover it w/o looking at the underlying IR 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. Makes sense. I think we may have two possible approaches to fix this:
This is a side project, and I'm not sure how critical it is. If the cost of implementing an acceptable fix exceeds the above two options, maybe we can defer it. |
||
Ptr->getUnderlyingValue()->stripPointerCasts())) | ||
if (GEP->isInBounds()) | ||
NewFlags = GEPNoWrapFlags::inBounds(); | ||
} | ||
auto *NewVEP = new VPVectorEndPointerRecipe( | ||
Ptr, &EVL, VEP->getIndexedTy(), NewFlags, VEP->getDebugLoc()); | ||
NewVEP->insertBefore(VEP); | ||
VEP->replaceAllUsesWith(NewVEP); | ||
VEP->eraseFromParent(); | ||
} | ||
} | ||
} | ||
|
||
/// Replace recipes with their EVL variants. | ||
static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) { | ||
Type *CanonicalIVType = Plan.getCanonicalIV()->getScalarType(); | ||
|
@@ -2198,12 +2221,8 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) { | |
PrevEVL = Builder.createScalarPhi({MaxEVL, &EVL}, DebugLoc(), "prev.evl"); | ||
} | ||
|
||
for (VPUser *U : to_vector(Plan.getVF().users())) { | ||
if (auto *R = dyn_cast<VPVectorEndPointerRecipe>(U)) | ||
R->setOperand(1, &EVL); | ||
} | ||
|
||
SmallVector<VPRecipeBase *> ToErase; | ||
replaceVFWithEVL(Plan.getVF(), EVL); | ||
|
||
for (VPValue *HeaderMask : collectAllHeaderMasks(Plan)) { | ||
for (VPUser *U : collectUsersRecursively(HeaderMask)) { | ||
|
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.
///
styleVPVectorEndPointerRecipe
?