-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RegAllocEvictAdvisor] Add minimum weight ratio heuristic. #98109
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
mgudim
wants to merge
2
commits into
llvm:main
Choose a base branch
from
mgudim:min-weight-ratio
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 all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5 | ||
# RUN: llc %s -mtriple=riscv64 -run-pass=greedy,virtregrewriter \ | ||
# RUN: -min-weight-ratio-needed-to-evict-hint=7.5 -o - | FileCheck %s | ||
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. To go back to what I was saying wrt 7.5. I'm not questioning that this gives you the best outcome in what you measured, what I was asking is why it is. |
||
|
||
# Due to the minimum weight heuristic (see the explanation of `MinWeightRatioNeededToEvictHint`) we are able to get rid of ALL the copies in the code below. When heuristic is disabled (`-min-weight-ratio-needed-to-evict-hint=1.0`) we end up with 3 copies. | ||
|
||
--- | | ||
source_filename = "test.c" | ||
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128" | ||
target triple = "riscv64" | ||
|
||
define dso_local i64 @caller(i64 %x) { | ||
entry: | ||
%add_ = add i64 %x, 1 | ||
call void @foo() | ||
ret i64 %add_ | ||
} | ||
|
||
declare void @foo() | ||
|
||
... | ||
--- | ||
name: caller | ||
alignment: 2 | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0.entry: | ||
liveins: $x10, $x1, $x8, $x9, $x18, $x19, $x20, $x21, $x22, $x23, $x24, $x25, $x26, $x27 | ||
|
||
; CHECK-LABEL: name: caller | ||
; CHECK: liveins: $x1, $x8, $x9, $x10, $x18, $x19, $x20, $x21, $x22, $x23, $x24, $x25, $x26, $x27 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: SD $x1, %stack.0, 0 :: (store (s64) into %stack.0) | ||
; CHECK-NEXT: renamable $x10 = ADDI killed renamable $x10, 1 | ||
; CHECK-NEXT: SD killed renamable $x10, %stack.1, 0 :: (store (s64) into %stack.1) | ||
; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $x2, implicit $x2 | ||
; CHECK-NEXT: PseudoCALL target-flags(riscv-call) @foo, csr_ilp32d_lp64d, implicit-def dead $x1, implicit-def $x2 | ||
; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $x2, implicit $x2 | ||
; CHECK-NEXT: $x10 = LD %stack.1, 0 :: (load (s64) from %stack.1) | ||
; CHECK-NEXT: $x1 = LD %stack.0, 0 :: (load (s64) from %stack.0) | ||
; CHECK-NEXT: PseudoRET implicit $x10, implicit $x1, implicit $x8, implicit $x9, implicit $x18, implicit $x19, implicit $x20, implicit $x21, implicit $x22, implicit $x23, implicit $x24, implicit $x25, implicit $x26, implicit $x27 | ||
%14:gpr = COPY $x27 | ||
%13:gpr = COPY $x26 | ||
%12:gpr = COPY $x25 | ||
%11:gpr = COPY $x24 | ||
%10:gpr = COPY $x23 | ||
%9:gpr = COPY $x22 | ||
%8:gpr = COPY $x21 | ||
%7:gpr = COPY $x20 | ||
%6:gpr = COPY $x19 | ||
%5:gpr = COPY $x18 | ||
%4:gprc_and_sr07 = COPY $x9 | ||
%3:gprc_and_sr07 = COPY $x8 | ||
%2:gpr = COPY $x1 | ||
%0:gpr = COPY $x10 | ||
%1:gpr = ADDI %0, 1 | ||
ADJCALLSTACKDOWN 0, 0, implicit-def dead $x2, implicit $x2 | ||
PseudoCALL target-flags(riscv-call) @foo, csr_ilp32d_lp64d, implicit-def dead $x1, implicit-def $x2 | ||
ADJCALLSTACKUP 0, 0, implicit-def dead $x2, implicit $x2 | ||
$x10 = COPY %1 | ||
$x1 = COPY %2 | ||
$x8 = COPY %3 | ||
$x9 = COPY %4 | ||
$x18 = COPY %5 | ||
$x19 = COPY %6 | ||
$x20 = COPY %7 | ||
$x21 = COPY %8 | ||
$x22 = COPY %9 | ||
$x23 = COPY %10 | ||
$x24 = COPY %11 | ||
$x25 = COPY %12 | ||
$x26 = COPY %13 | ||
$x27 = COPY %14 | ||
PseudoRET implicit $x10, implicit $x1, implicit $x8, implicit $x9, implicit $x18, implicit $x19, implicit $x20, implicit $x21, implicit $x22, implicit $x23, implicit $x24, implicit $x25, implicit $x26, implicit $x27 | ||
|
||
... |
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.
The
CanSplit
doesn't make much sense to me here.Could you explain why this is desirable to check for this here?