-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[VPlan] Model address separately. #72164
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
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 | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1209,6 +1209,59 @@ void VPWidenGEPRecipe::print(raw_ostream &O, const Twine &Indent, | |||||||||||||||
} | ||||||||||||||||
#endif | ||||||||||||||||
|
||||||||||||||||
void VPVectorPointerRecipe ::execute(VPTransformState &State) { | ||||||||||||||||
auto &Builder = State.Builder; | ||||||||||||||||
State.setDebugLocFrom(getDebugLoc()); | ||||||||||||||||
for (unsigned Part = 0; Part < State.UF; ++Part) { | ||||||||||||||||
// Calculate the pointer for the specific unroll-part. | ||||||||||||||||
Value *PartPtr = nullptr; | ||||||||||||||||
// 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()->getModule()->getDataLayout(); | ||||||||||||||||
Type *IndexTy = State.VF.isScalable() && (IsReverse || Part > 0) | ||||||||||||||||
? DL.getIndexType(IndexedTy->getPointerTo()) | ||||||||||||||||
: Builder.getInt32Ty(); | ||||||||||||||||
Comment on lines
+1218
to
+1224
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 recipe holds IndexTy to avoid the need to look it up.
Suggested change
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 recipe stores the indexed type, which is different to the index type (integer type used for the indices of the generated GEP). Left as is for now. |
||||||||||||||||
Value *Ptr = State.get(getOperand(0), VPIteration(0, 0)); | ||||||||||||||||
bool InBounds = false; | ||||||||||||||||
if (auto *GEP = dyn_cast<GetElementPtrInst>(Ptr->stripPointerCasts())) | ||||||||||||||||
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): should this 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. Thanks, the inbounds info should be recorded in the recipe, which I'll do as follow-up. |
||||||||||||||||
InBounds = GEP->isInBounds(); | ||||||||||||||||
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 = -Part * RunTimeVF | ||||||||||||||||
Value *NumElt = Builder.CreateMul( | ||||||||||||||||
ConstantInt::get(IndexTy, -(int64_t)Part), RunTimeVF); | ||||||||||||||||
// LastLane = 1 - RunTimeVF | ||||||||||||||||
Value *LastLane = | ||||||||||||||||
Builder.CreateSub(ConstantInt::get(IndexTy, 1), RunTimeVF); | ||||||||||||||||
PartPtr = Builder.CreateGEP(IndexedTy, Ptr, NumElt, "", InBounds); | ||||||||||||||||
PartPtr = Builder.CreateGEP(IndexedTy, PartPtr, LastLane, "", InBounds); | ||||||||||||||||
} else { | ||||||||||||||||
Value *Increment = createStepForVF(Builder, IndexTy, State.VF, Part); | ||||||||||||||||
PartPtr = Builder.CreateGEP(IndexedTy, Ptr, Increment, "", InBounds); | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
State.set(this, PartPtr, Part); | ||||||||||||||||
} | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) | ||||||||||||||||
void VPVectorPointerRecipe::print(raw_ostream &O, const Twine &Indent, | ||||||||||||||||
VPSlotTracker &SlotTracker) const { | ||||||||||||||||
O << Indent; | ||||||||||||||||
printAsOperand(O, SlotTracker); | ||||||||||||||||
O << " = vector-pointer "; | ||||||||||||||||
if (IsReverse) | ||||||||||||||||
O << "(reverse) "; | ||||||||||||||||
|
||||||||||||||||
printOperands(O, SlotTracker); | ||||||||||||||||
} | ||||||||||||||||
#endif | ||||||||||||||||
|
||||||||||||||||
void VPBlendRecipe::execute(VPTransformState &State) { | ||||||||||||||||
State.setDebugLocFrom(getDebugLoc()); | ||||||||||||||||
// We know that all PHIs in non-header blocks are converted into | ||||||||||||||||
|
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: "only neede[d] for" typo above.
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.
Fixed in 516cc98