-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RISCV] Support load clustering in the MachineScheduler (off by default) #73754
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
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,43 @@ | ||
; REQUIRES: asserts | ||
; RUN: llc -mtriple=riscv32 -verify-misched -debug-only=machine-scheduler -o - 2>&1 < %s \ | ||
; RUN: | FileCheck -check-prefix=NOCLUSTER %s | ||
; RUN: llc -mtriple=riscv64 -verify-misched -debug-only=machine-scheduler -o - 2>&1 < %s \ | ||
; RUN: | FileCheck -check-prefix=NOCLUSTER %s | ||
; RUN: llc -mtriple=riscv32 -riscv-misched-load-clustering -verify-misched \ | ||
; RUN: -debug-only=machine-scheduler -o - 2>&1 < %s \ | ||
; RUN: | FileCheck -check-prefix=LDCLUSTER %s | ||
; RUN: llc -mtriple=riscv64 -riscv-misched-load-clustering -verify-misched \ | ||
; RUN: -debug-only=machine-scheduler -o - 2>&1 < %s \ | ||
; RUN: | FileCheck -check-prefix=LDCLUSTER %s | ||
|
||
|
||
define i32 @load_clustering_1(ptr nocapture %p) { | ||
; NOCLUSTER: ********** MI Scheduling ********** | ||
; NOCLUSTER-LABEL: load_clustering_1:%bb.0 | ||
; NOCLUSTER: *** Final schedule for %bb.0 *** | ||
; NOCLUSTER: SU(1): %1:gpr = LW %0:gpr, 12 | ||
; NOCLUSTER: SU(2): %2:gpr = LW %0:gpr, 8 | ||
; NOCLUSTER: SU(4): %4:gpr = LW %0:gpr, 4 | ||
; NOCLUSTER: SU(5): %6:gpr = LW %0:gpr, 16 | ||
; | ||
; LDCLUSTER: ********** MI Scheduling ********** | ||
; LDCLUSTER-LABEL: load_clustering_1:%bb.0 | ||
; LDCLUSTER: *** Final schedule for %bb.0 *** | ||
; LDCLUSTER: SU(5): %6:gpr = LW %0:gpr, 16 | ||
; LDCLUSTER: SU(1): %1:gpr = LW %0:gpr, 12 | ||
; LDCLUSTER: SU(2): %2:gpr = LW %0:gpr, 8 | ||
; LDCLUSTER: SU(4): %4:gpr = LW %0:gpr, 4 | ||
entry: | ||
%arrayidx0 = getelementptr inbounds i32, ptr %p, i32 3 | ||
%val0 = load i32, i32* %arrayidx0 | ||
%arrayidx1 = getelementptr inbounds i32, ptr %p, i32 2 | ||
%val1 = load i32, i32* %arrayidx1 | ||
%tmp0 = add i32 %val0, %val1 | ||
%arrayidx2 = getelementptr inbounds i32, ptr %p, i32 1 | ||
%val2 = load i32, i32* %arrayidx2 | ||
%tmp1 = add i32 %tmp0, %val2 | ||
%arrayidx3 = getelementptr inbounds i32, ptr %p, i32 4 | ||
%val3 = load i32, i32* %arrayidx3 | ||
%tmp2 = add i32 %tmp1, %val3 | ||
ret i32 %tmp2 | ||
} |
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.
Hi. Can there be a hook to implement the load/store fusion (like with same base register and different offset) like PowerPC does?
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.
What kind of logic were you imagining? The shouldClusterMemOps logic we're using right now should in general cluster in far more cases than the PPC implementation (which as you say, has a hook to pick up just those cases what may support load/store fusion).
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.
Oh. What I mean is too generic. And constraint to require the same opcode with two cluster load/store and the memory addresses also need consecutive, which means second offset = first offset + first width.
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.
Ooops. I see the follow-up PR #73778, that what I want.