-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[LV][VPlan] Reduce register usage of VPEVLBasedIVPHIRecipe. #154482
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
ElvisWang123
merged 5 commits into
llvm:main
from
ElvisWang123:lv-reg-RISCV-EVL-phi-fix
Aug 20, 2025
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3990d82
Precommit test case.
ElvisWang123 ec2e9aa
[LV][VPlan] Reduce register usage of VPEVLBasedIVPHIRecipe.
ElvisWang123 c6eb21b
address comments.
ElvisWang123 0a10d12
!fixup, add newline and remove unneed runs.
ElvisWang123 918309a
Merge branch 'main' into lv-reg-RISCV-EVL-phi-fix
ElvisWang123 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
37 changes: 37 additions & 0 deletions
37
llvm/test/Transforms/LoopVectorize/RISCV/reg-usage-maxbandwidth.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,37 @@ | ||||||||
| ; REQUIRES: asserts | ||||||||
| ; RUN: opt -passes=loop-vectorize -mtriple riscv64 -mattr=+v -vectorizer-maximize-bandwidth -debug-only=loop-vectorize,vplan -disable-output -S < %s 2>&1 | FileCheck %s --check-prefixes=CHECK-REGS-VP | ||||||||
| ; RUN: opt -passes=loop-vectorize -mtriple riscv64 -mattr=+v -vectorizer-maximize-bandwidth -debug-only=loop-vectorize -disable-output -force-target-num-vector-regs=1 -S < %s 2>&1 | FileCheck %s --check-prefixes=CHECK-NOREGS-VP | ||||||||
| define i32 @dotp(ptr %a, ptr %b) { | ||||||||
|
Contributor
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, should probably have an extra newline
Suggested change
|
||||||||
| ; CHECK-REGS-VP: LV(REG): VF = vscale x 16 | ||||||||
| ; CHECK-REGS-VP-NEXT: LV(REG): Found max usage: 2 item | ||||||||
| ; CHECK-REGS-VP-NEXT: LV(REG): RegisterClass: RISCV::GPRRC, 6 registers | ||||||||
| ; CHECK-REGS-VP-NEXT: LV(REG): RegisterClass: RISCV::VRRC, 24 registers | ||||||||
| ; CHECK-REGS-VP-NEXT: LV(REG): Found invariant usage: 1 item | ||||||||
| ; CHECK-REGS-VP-NEXT: LV(REG): RegisterClass: RISCV::GPRRC, 1 registers | ||||||||
| ; CHECK-REGS-VP: LV: Selecting VF: vscale x 16. | ||||||||
| ; | ||||||||
| ; CHECK-NOREGS-VP: LV(REG): Not considering vector loop of width vscale x 8 because it uses too many registers | ||||||||
| ; CHECK-NOREGS-VP: LV(REG): Not considering vector loop of width vscale x 16 because it uses too many registers | ||||||||
| ; CHECK-NOREGS-VP: LV: Selecting VF: vscale x 4. | ||||||||
| entry: | ||||||||
| br label %for.body | ||||||||
|
|
||||||||
| for.body: ; preds = %for.body, %entry | ||||||||
| %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] | ||||||||
| %accum = phi i32 [ 0, %entry ], [ %add, %for.body ] | ||||||||
| %gep.a = getelementptr i8, ptr %a, i64 %iv | ||||||||
| %load.a = load i8, ptr %gep.a, align 1 | ||||||||
| %ext.a = zext i8 %load.a to i32 | ||||||||
| %gep.b = getelementptr i8, ptr %b, i64 %iv | ||||||||
| %load.b = load i8, ptr %gep.b, align 1 | ||||||||
| %ext.b = zext i8 %load.b to i32 | ||||||||
| %mul = mul i32 %ext.b, %ext.a | ||||||||
| %sub = sub i32 0, %mul | ||||||||
| %add = add i32 %accum, %sub | ||||||||
| %iv.next = add i64 %iv, 1 | ||||||||
| %exitcond.not = icmp eq i64 %iv.next, 1024 | ||||||||
| br i1 %exitcond.not, label %for.exit, label %for.body | ||||||||
|
|
||||||||
| for.exit: ; preds = %for.body | ||||||||
| ret i32 %add | ||||||||
| } | ||||||||
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 don't think this RUN line is necessary, I think the diff from the debug output on the first RUN line is good enough. But I'm not strongly opinionated about this, I'll leave this up to you :)