-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[LV] Add a flag to conservatively choose a larger vector factor when maximizing bandwidth #156012
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
ytmukai
wants to merge
2
commits into
llvm:main
Choose a base branch
from
ytmukai:cons-max-vf
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 1 commit
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
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
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
58 changes: 58 additions & 0 deletions
58
llvm/test/Transforms/LoopVectorize/AArch64/maximize-bandwidth-conservatively.ll
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 |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| ; REQUIRES: asserts | ||
| ; RUN: opt < %s -mtriple aarch64-linux-gnu -mattr=+sve -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -debug-only=loop-vectorize 2>&1 | FileCheck %s | ||
| ; RUN: opt < %s -mtriple aarch64-linux-gnu -mattr=+sve -passes=loop-vectorize -vectorizer-maximize-bandwidth -vectorizer-maximize-bandwidth-conservatively -S -debug-only=loop-vectorize 2>&1 | FileCheck %s --check-prefix=CHECK-CONS | ||
|
|
||
| define void @f(i32 %n, ptr noalias %a, ptr %b, ptr %c) { | ||
| ; The following loop is an example where choosing a larger vector width reduces | ||
| ; the number of instructions but may lead to performance degradation due to the | ||
| ; FP pipeline becoming a bottleneck. | ||
| ; | ||
| ; void f(int n, short *restrict a, long *b, double *c) { | ||
| ; for (int i = 0; i < n; i++) { | ||
| ; a[i] = b[i] + c[i]; | ||
| ; } | ||
| ; } | ||
|
|
||
| ; In the usual cost model, vscale x 8 is chosen. | ||
| ; CHECK: Cost for VF vscale x 2: 8 (Estimated cost per lane: 4.0) | ||
| ; CHECK: Cost for VF vscale x 4: 14 (Estimated cost per lane: 3.5) | ||
| ; CHECK: Cost for VF vscale x 8: 26 (Estimated cost per lane: 3.2) | ||
| ; CHECK: LV: Selecting VF: vscale x 8. | ||
|
|
||
| ; In a conservative cost model, a larger vector width is chosen only if it is | ||
| ; superior when compared solely based on the cost of the FP pipeline, in | ||
| ; addition to the usual model. | ||
| ; CHECK-CONS: Cost for VF vscale x 2: 3 (Estimated cost per lane: 1.5) | ||
| ; CHECK-CONS: Cost for VF vscale x 4: 7 (Estimated cost per lane: 1.8) | ||
| ; CHECK-CONS: Cost for VF vscale x 8: 15 (Estimated cost per lane: 1.9) | ||
| ; CHECK-CONS: LV: Selecting VF: vscale x 2. | ||
|
|
||
| entry: | ||
| %cmp10 = icmp sgt i32 %n, 0 | ||
| br i1 %cmp10, label %for.body.preheader, label %for.cond.cleanup | ||
|
|
||
| for.body.preheader: ; preds = %entry | ||
| %wide.trip.count = zext nneg i32 %n to i64 | ||
| br label %for.body | ||
|
|
||
| for.cond.cleanup.loopexit: ; preds = %for.body | ||
| br label %for.cond.cleanup | ||
|
|
||
| for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry | ||
| ret void | ||
|
|
||
| for.body: ; preds = %for.body.preheader, %for.body | ||
| %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ] | ||
| %arrayidx = getelementptr inbounds nuw i64, ptr %b, i64 %indvars.iv | ||
| %0 = load i64, ptr %arrayidx, align 8 | ||
| %conv = sitofp i64 %0 to double | ||
| %arrayidx2 = getelementptr inbounds nuw double, ptr %c, i64 %indvars.iv | ||
| %1 = load double, ptr %arrayidx2, align 8 | ||
| %add = fadd double %1, %conv | ||
| %conv3 = fptosi double %add to i16 | ||
| %arrayidx5 = getelementptr inbounds nuw i16, ptr %a, i64 %indvars.iv | ||
| store i16 %conv3, ptr %arrayidx5, align 2 | ||
| %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 | ||
| %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count | ||
| br i1 %exitcond.not, label %for.cond.cleanup.loopexit, label %for.body | ||
| } |
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.
I'm not sure why we need a new flag to force enabling the max bandwidth, since one already exists in LoopVectorize.cpp -
vectorizer-maximize-bandwidth.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.
Thank you. I did not intend to include this part in this patch. Removed.