-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[VPlan] Emit VPVectorEndPointerRecipe for reverse interleave pointer adjustment #144864
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
Open
Mel-Chen
wants to merge
4
commits into
llvm:main
Choose a base branch
from
Mel-Chen:widen-vector-pointer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1695,17 +1695,21 @@ class VPWidenGEPRecipe : public VPRecipeWithIRFlags { | |||||
|
||||||
/// A recipe to compute a pointer to the last element of each part of a widened | ||||||
/// memory access for widened memory accesses of IndexedTy. Used for | ||||||
/// VPWidenMemoryRecipes that are reversed. | ||||||
/// VPWidenMemoryRecipes or VPInterleaveRecipes that are reversed. | ||||||
class VPVectorEndPointerRecipe : public VPRecipeWithIRFlags, | ||||||
public VPUnrollPartAccessor<2> { | ||||||
Type *IndexedTy; | ||||||
|
||||||
int64_t Stride; | ||||||
|
||||||
public: | ||||||
VPVectorEndPointerRecipe(VPValue *Ptr, VPValue *VF, Type *IndexedTy, | ||||||
GEPNoWrapFlags GEPFlags, DebugLoc DL) | ||||||
int64_t Stride, GEPNoWrapFlags GEPFlags, DebugLoc DL) | ||||||
: VPRecipeWithIRFlags(VPDef::VPVectorEndPointerSC, | ||||||
ArrayRef<VPValue *>({Ptr, VF}), GEPFlags, DL), | ||||||
IndexedTy(IndexedTy) {} | ||||||
IndexedTy(IndexedTy), Stride(Stride) { | ||||||
assert(Stride != 0 && "Unexpected stride"); | ||||||
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.
Suggested change
|
||||||
} | ||||||
|
||||||
VP_CLASSOF_IMPL(VPDef::VPVectorEndPointerSC) | ||||||
|
||||||
|
@@ -1737,7 +1741,8 @@ class VPVectorEndPointerRecipe : public VPRecipeWithIRFlags, | |||||
|
||||||
VPVectorEndPointerRecipe *clone() override { | ||||||
return new VPVectorEndPointerRecipe(getOperand(0), getVFValue(), IndexedTy, | ||||||
getGEPNoWrapFlags(), getDebugLoc()); | ||||||
Stride, getGEPNoWrapFlags(), | ||||||
getDebugLoc()); | ||||||
} | ||||||
|
||||||
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2489,6 +2489,22 @@ void VPlanTransforms::createInterleaveGroups( | |
Addr = InBounds ? B.createInBoundsPtrAdd(InsertPos->getAddr(), OffsetVPV) | ||
: B.createPtrAdd(InsertPos->getAddr(), OffsetVPV); | ||
} | ||
// If the group is reverse, adjust the index to refer to the last vector | ||
// lane instead of the first. We adjust the index from the first vector | ||
// lane, rather than directly getting the pointer for lane VF - 1, because | ||
// the pointer operand of the interleaved access is supposed to be uniform. | ||
if (IG->isReverse()) { | ||
auto *GEP = dyn_cast<GetElementPtrInst>( | ||
getLoadStorePointerOperand(IRInsertPos)->stripPointerCasts()); | ||
Comment on lines
+2497
to
+2498
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. would be good to share the logic to determine inbounds from the GEP with similar code above |
||
auto *ReversePtr = new VPVectorEndPointerRecipe( | ||
Addr, &Plan.getVF(), getLoadStoreType(IRInsertPos), | ||
-(int64_t)IG->getFactor(), | ||
GEP && GEP->isInBounds() ? GEPNoWrapFlags::inBounds() | ||
: GEPNoWrapFlags::none(), | ||
InsertPos->getDebugLoc()); | ||
ReversePtr->insertBefore(InsertPos); | ||
Addr = ReversePtr; | ||
} | ||
auto *VPIG = new VPInterleaveRecipe(IG, Addr, StoredValues, | ||
InsertPos->getMask(), NeedsMaskForGaps, InsertPos->getDebugLoc()); | ||
VPIG->insertBefore(InsertPos); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Needs a comment