-
Notifications
You must be signed in to change notification settings - Fork 14k
[LV] Use getFixedValue instead of getKnownMinValue when appropriate #143526
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 all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -872,7 +872,7 @@ void VPInstruction::execute(VPTransformState &State) { | |
isVectorToScalar() || isSingleScalar()); | ||
bool GeneratesPerAllLanes = doesGeneratePerAllLanes(); | ||
if (GeneratesPerAllLanes) { | ||
for (unsigned Lane = 0, NumLanes = State.VF.getKnownMinValue(); | ||
for (unsigned Lane = 0, NumLanes = State.VF.getFixedValue(); | ||
Lane != NumLanes; ++Lane) { | ||
Value *GeneratedValue = generatePerLane(State, VPLane(Lane)); | ||
assert(GeneratedValue && "generatePerLane must produce a value"); | ||
|
@@ -2792,8 +2792,7 @@ void VPReplicateRecipe::execute(VPTransformState &State) { | |
} | ||
|
||
// Generate scalar instances for all VF lanes. | ||
assert(!State.VF.isScalable() && "Can't scalarize a scalable vector"); | ||
const unsigned EndLane = State.VF.getKnownMinValue(); | ||
const unsigned EndLane = State.VF.getFixedValue(); | ||
for (unsigned Lane = 0; Lane < EndLane; ++Lane) | ||
scalarizeInstruction(UI, this, VPLane(Lane), State); | ||
} | ||
|
@@ -2846,7 +2845,7 @@ InstructionCost VPReplicateRecipe::computeCost(ElementCount VF, | |
UI->getOpcode(), ResultTy, CostKind, | ||
{TargetTransformInfo::OK_AnyValue, TargetTransformInfo::OP_None}, | ||
Op2Info, Operands, UI, &Ctx.TLI) * | ||
(isSingleScalar() ? 1 : VF.getKnownMinValue()); | ||
(isSingleScalar() ? 1 : VF.getFixedValue()); | ||
} | ||
} | ||
|
||
|
@@ -3399,7 +3398,7 @@ void VPInterleaveRecipe::execute(VPTransformState &State) { | |
Value *ResBlockInMask = State.get(BlockInMask); | ||
Value *ShuffledMask = State.Builder.CreateShuffleVector( | ||
ResBlockInMask, | ||
createReplicatedMask(InterleaveFactor, State.VF.getKnownMinValue()), | ||
createReplicatedMask(InterleaveFactor, State.VF.getFixedValue()), | ||
"interleaved.mask"); | ||
return MaskForGaps ? State.Builder.CreateBinOp(Instruction::And, | ||
ShuffledMask, MaskForGaps) | ||
|
@@ -3411,8 +3410,8 @@ void VPInterleaveRecipe::execute(VPTransformState &State) { | |
if (isa<LoadInst>(Instr)) { | ||
Value *MaskForGaps = nullptr; | ||
if (NeedsMaskForGaps) { | ||
MaskForGaps = createBitMaskForGaps(State.Builder, | ||
State.VF.getKnownMinValue(), *Group); | ||
MaskForGaps = | ||
createBitMaskForGaps(State.Builder, State.VF.getFixedValue(), *Group); | ||
assert(MaskForGaps && "Mask for Gaps is required but it is null"); | ||
} | ||
|
||
|
@@ -3463,6 +3462,7 @@ void VPInterleaveRecipe::execute(VPTransformState &State) { | |
|
||
return; | ||
} | ||
assert(!State.VF.isScalable() && "VF is assumed to be non scalable."); | ||
|
||
// For each member in the group, shuffle out the appropriate data from the | ||
// wide loads. | ||
|
@@ -3475,13 +3475,12 @@ void VPInterleaveRecipe::execute(VPTransformState &State) { | |
continue; | ||
|
||
auto StrideMask = | ||
createStrideMask(I, InterleaveFactor, State.VF.getKnownMinValue()); | ||
createStrideMask(I, InterleaveFactor, State.VF.getFixedValue()); | ||
Value *StridedVec = | ||
State.Builder.CreateShuffleVector(NewLoad, StrideMask, "strided.vec"); | ||
|
||
// If this member has different type, cast the result type. | ||
if (Member->getType() != ScalarTy) { | ||
assert(!State.VF.isScalable() && "VF is assumed to be non scalable."); | ||
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. I guess it would be fine to drop this here as it is covered by the getFixedValue above, but it may be clearer to keep the assert here or add it somewhere above? |
||
VectorType *OtherVTy = VectorType::get(Member->getType(), State.VF); | ||
StridedVec = | ||
createBitOrPointerCast(State.Builder, StridedVec, OtherVTy, DL); | ||
|
@@ -3817,7 +3816,7 @@ VPFirstOrderRecurrencePHIRecipe::computeCost(ElementCount VF, | |
if (VF.isScalar()) | ||
return Ctx.TTI.getCFInstrCost(Instruction::PHI, Ctx.CostKind); | ||
|
||
if (VF.isScalable() && VF.getKnownMinValue() == 1) | ||
if (VF == ElementCount::getScalable(1)) | ||
return InstructionCost::getInvalid(); | ||
|
||
return 0; | ||
|
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.
May I ask where it is guaranteed that the VF is not scalable?
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.
This is an existing invariant, in the bit below there's an assertion that
!VF.isScalable()
if IsSingleScalar is falseThere 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.
Good question, but no tests broke (including LLVM test suite) when I made this change so either:
and also I think the code is already broken for scalable vectors because the last lane isn't VF.getKnownMinValue() - 1.
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.
So I reasoned that we may as well strength the code, since it looks like we're effectively assuming fixed-width already.