-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[LV][VPlan] Use VF VPValue in VPVectorPointerRecipe #110974
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8942e28
[LV][VPlan] Use VF VPValue in VPVectorPointerRecipe
arcbbb 9f1c301
Address comments
arcbbb fd73197
Update llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
arcbbb 7a4daf5
Update llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
arcbbb 142ea90
Update llvm/lib/Transforms/Vectorize/VPlan.h
arcbbb 6a575e2
Address comments
arcbbb 0a500c7
Add getGEPIndexTy utility function to avoid duplication
arcbbb d46752d
Make VPReverVectorPointer return false in mayHaveSideEffects
arcbbb 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
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 |
|---|---|---|
|
|
@@ -1813,38 +1813,59 @@ void VPWidenGEPRecipe::print(raw_ostream &O, const Twine &Indent, | |
| } | ||
| #endif | ||
|
|
||
| void VPReverseVectorPointerRecipe ::execute(VPTransformState &State) { | ||
| auto &Builder = State.Builder; | ||
| State.setDebugLocFrom(getDebugLoc()); | ||
| unsigned CurrentPart = getUnrollPart(*this); | ||
| // Use i32 for the gep index type when the value is constant, | ||
| // or query DataLayout for a more suitable index type otherwise. | ||
| const DataLayout &DL = Builder.GetInsertBlock()->getDataLayout(); | ||
| Type *IndexTy = State.VF.isScalable() | ||
| ? DL.getIndexType(IndexedTy->getPointerTo()) | ||
| : Builder.getInt32Ty(); | ||
|
||
| Value *Ptr = State.get(getOperand(0), VPLane(0)); | ||
arcbbb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| bool InBounds = isInBounds(); | ||
arcbbb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // the wide store needs to start at the last vector element. | ||
arcbbb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Value *RunTimeVF = State.get(getVFValue(), VPLane(0)); | ||
| if (IndexTy != RunTimeVF->getType()) | ||
| RunTimeVF = Builder.CreateZExtOrTrunc(RunTimeVF, IndexTy); | ||
| // NumElt = -CurrentPart * RunTimeVF | ||
| Value *NumElt = Builder.CreateMul( | ||
| ConstantInt::get(IndexTy, -(int64_t)CurrentPart), RunTimeVF); | ||
| // LastLane = 1 - RunTimeVF | ||
| Value *LastLane = Builder.CreateSub(ConstantInt::get(IndexTy, 1), RunTimeVF); | ||
| Value *ResultPtr = Builder.CreateGEP(IndexedTy, Ptr, NumElt, "", InBounds); | ||
| ResultPtr = Builder.CreateGEP(IndexedTy, ResultPtr, LastLane, "", InBounds); | ||
|
|
||
| State.set(this, ResultPtr, /*IsScalar*/ true); | ||
| } | ||
|
|
||
| #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) | ||
| void VPReverseVectorPointerRecipe::print(raw_ostream &O, const Twine &Indent, | ||
| VPSlotTracker &SlotTracker) const { | ||
| O << Indent; | ||
| printAsOperand(O, SlotTracker); | ||
| O << " = reverse-vector-pointer "; | ||
arcbbb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| printOperands(O, SlotTracker); | ||
| } | ||
| #endif | ||
|
|
||
| void VPVectorPointerRecipe ::execute(VPTransformState &State) { | ||
| auto &Builder = State.Builder; | ||
| State.setDebugLocFrom(getDebugLoc()); | ||
| unsigned CurrentPart = getUnrollPart(*this); | ||
| // Use i32 for the gep index type when the value is constant, | ||
| // or query DataLayout for a more suitable index type otherwise. | ||
| const DataLayout &DL = Builder.GetInsertBlock()->getDataLayout(); | ||
| Type *IndexTy = State.VF.isScalable() && (IsReverse || CurrentPart > 0) | ||
| Type *IndexTy = State.VF.isScalable() && (CurrentPart > 0) | ||
arcbbb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ? DL.getIndexType(Builder.getPtrTy(0)) | ||
| : Builder.getInt32Ty(); | ||
| Value *Ptr = State.get(getOperand(0), VPLane(0)); | ||
| bool InBounds = isInBounds(); | ||
|
|
||
| Value *ResultPtr = nullptr; | ||
| if (IsReverse) { | ||
| // If the address is consecutive but reversed, then the | ||
| // wide store needs to start at the last vector element. | ||
| // RunTimeVF = VScale * VF.getKnownMinValue() | ||
| // For fixed-width VScale is 1, then RunTimeVF = VF.getKnownMinValue() | ||
| Value *RunTimeVF = getRuntimeVF(Builder, IndexTy, State.VF); | ||
| // NumElt = -CurrentPart * RunTimeVF | ||
| Value *NumElt = Builder.CreateMul( | ||
| ConstantInt::get(IndexTy, -(int64_t)CurrentPart), RunTimeVF); | ||
| // LastLane = 1 - RunTimeVF | ||
| Value *LastLane = | ||
| Builder.CreateSub(ConstantInt::get(IndexTy, 1), RunTimeVF); | ||
| ResultPtr = Builder.CreateGEP(IndexedTy, Ptr, NumElt, "", InBounds); | ||
| ResultPtr = Builder.CreateGEP(IndexedTy, ResultPtr, LastLane, "", InBounds); | ||
| } else { | ||
| Value *Increment = createStepForVF(Builder, IndexTy, State.VF, CurrentPart); | ||
| ResultPtr = Builder.CreateGEP(IndexedTy, Ptr, Increment, "", InBounds); | ||
| } | ||
| Value *Increment = createStepForVF(Builder, IndexTy, State.VF, CurrentPart); | ||
| Value *ResultPtr = Builder.CreateGEP(IndexedTy, Ptr, Increment, "", InBounds); | ||
|
|
||
| State.set(this, ResultPtr, /*IsScalar*/ true); | ||
| } | ||
|
|
@@ -1855,8 +1876,6 @@ void VPVectorPointerRecipe::print(raw_ostream &O, const Twine &Indent, | |
| O << Indent; | ||
| printAsOperand(O, SlotTracker); | ||
| O << " = vector-pointer "; | ||
| if (IsReverse) | ||
| O << "(reverse) "; | ||
|
|
||
| printOperands(O, SlotTracker); | ||
| } | ||
|
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.