-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RISCV] Add register bank and instruction selection support for FP G_SELECT. #72726
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
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0792f67
[RISCV] Add register bank and instruction selection support for G_SEL…
topperc 4704a36
fixup! clang-format
topperc 3b69d37
Add f32 test for rv64.
topperc 3353375
fixup! Update comment copy/pasted from AArch64.
topperc 0d20ddf
fixup! Add s32 regbank test for rv64.
topperc fa54dde
fixup! add more tests.
topperc 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
33 changes: 33 additions & 0 deletions
33
llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/fp-select-rv32.mir
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,33 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py | ||
# RUN: llc -mtriple=riscv32 -mattr=+d -run-pass=instruction-select \ | ||
# RUN: -simplify-mir -verify-machineinstrs %s -o - | FileCheck %s | ||
|
||
--- | ||
name: fp_select_s32 | ||
legalized: true | ||
regBankSelected: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0.entry: | ||
liveins: $x10, $f10_f, $f11_f | ||
|
||
; CHECK-LABEL: name: fp_select_s32 | ||
; CHECK: liveins: $x10, $f10_f, $f11_f | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 | ||
; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr32 = COPY $f10_f | ||
; CHECK-NEXT: [[COPY2:%[0-9]+]]:fpr32 = COPY $f11_f | ||
; CHECK-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[COPY]], 1 | ||
; CHECK-NEXT: [[Select_FPR32_Using_CC_GPR:%[0-9]+]]:fpr32 = Select_FPR32_Using_CC_GPR [[ANDI]], $x0, 1, [[COPY1]], [[COPY2]] | ||
; CHECK-NEXT: $f10_f = COPY [[Select_FPR32_Using_CC_GPR]] | ||
; CHECK-NEXT: PseudoRET implicit $f10_f | ||
%0:gprb(s32) = COPY $x10 | ||
%1:fprb(s32) = COPY $f10_f | ||
%2:fprb(s32) = COPY $f11_f | ||
%3:gprb(s32) = G_CONSTANT i32 1 | ||
%4:gprb(s32) = G_AND %0, %3 | ||
%5:fprb(s32) = G_SELECT %4(s32), %1, %2 | ||
$f10_f = COPY %5(s32) | ||
PseudoRET implicit $f10_f | ||
|
||
michaelmaitland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
... |
64 changes: 64 additions & 0 deletions
64
llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/fp-select-rv64.mir
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,64 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py | ||
# RUN: llc -mtriple=riscv64 -mattr=+d -run-pass=instruction-select \ | ||
# RUN: -simplify-mir -verify-machineinstrs %s -o - | FileCheck %s | ||
|
||
--- | ||
name: fp_select_s32 | ||
alignment: 1 | ||
legalized: true | ||
regBankSelected: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0.entry: | ||
liveins: $x10, $f10_d, $f11_d | ||
|
||
; CHECK-LABEL: name: fp_select_s32 | ||
; CHECK: liveins: $x10, $f10_d, $f11_d | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 | ||
; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr32 = COPY $f10_f | ||
; CHECK-NEXT: [[COPY2:%[0-9]+]]:fpr32 = COPY $f11_f | ||
; CHECK-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[COPY]], 1 | ||
; CHECK-NEXT: [[Select_FPR32_Using_CC_GPR:%[0-9]+]]:fpr32 = Select_FPR32_Using_CC_GPR [[ANDI]], $x0, 1, [[COPY1]], [[COPY2]] | ||
; CHECK-NEXT: $f10_f = COPY [[Select_FPR32_Using_CC_GPR]] | ||
; CHECK-NEXT: PseudoRET implicit $f10_f | ||
%0:gprb(s64) = COPY $x10 | ||
%1:fprb(s32) = COPY $f10_f | ||
%2:fprb(s32) = COPY $f11_f | ||
%3:gprb(s64) = G_CONSTANT i64 1 | ||
%4:gprb(s64) = G_AND %0, %3 | ||
%5:fprb(s32) = G_SELECT %4(s64), %1, %2 | ||
$f10_f = COPY %5(s32) | ||
PseudoRET implicit $f10_f | ||
|
||
... | ||
--- | ||
name: fp_select_s64 | ||
alignment: 1 | ||
legalized: true | ||
regBankSelected: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0.entry: | ||
liveins: $x10, $f10_d, $f11_d | ||
|
||
; CHECK-LABEL: name: fp_select_s64 | ||
; CHECK: liveins: $x10, $f10_d, $f11_d | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 | ||
; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr64 = COPY $f10_d | ||
; CHECK-NEXT: [[COPY2:%[0-9]+]]:fpr64 = COPY $f11_d | ||
; CHECK-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[COPY]], 1 | ||
; CHECK-NEXT: [[Select_FPR64_Using_CC_GPR:%[0-9]+]]:fpr64 = Select_FPR64_Using_CC_GPR [[ANDI]], $x0, 1, [[COPY1]], [[COPY2]] | ||
; CHECK-NEXT: $f10_d = COPY [[Select_FPR64_Using_CC_GPR]] | ||
; CHECK-NEXT: PseudoRET implicit $f10_d | ||
%0:gprb(s64) = COPY $x10 | ||
%1:fprb(s64) = COPY $f10_d | ||
%2:fprb(s64) = COPY $f11_d | ||
%3:gprb(s64) = G_CONSTANT i64 1 | ||
%4:gprb(s64) = G_AND %0, %3 | ||
%5:fprb(s64) = G_SELECT %4(s64), %1, %2 | ||
$f10_d = COPY %5(s64) | ||
PseudoRET implicit $f10_d | ||
|
||
... |
152 changes: 152 additions & 0 deletions
152
llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/fp-select-rv32.mir
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,152 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py | ||
# RUN: llc -mtriple=riscv32 -mattr=+d -run-pass=regbankselect \ | ||
# RUN: -disable-gisel-legality-check -simplify-mir -verify-machineinstrs %s \ | ||
# RUN: -o - | FileCheck -check-prefix=RV32I %s | ||
|
||
--- | ||
name: fp_select_s32 | ||
legalized: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0.entry: | ||
liveins: $x10, $f10_f, $f11_f | ||
|
||
; RV32I-LABEL: name: fp_select_s32 | ||
; RV32I: liveins: $x10, $f10_f, $f11_f | ||
; RV32I-NEXT: {{ $}} | ||
; RV32I-NEXT: [[COPY:%[0-9]+]]:gprb(s32) = COPY $x10 | ||
; RV32I-NEXT: [[COPY1:%[0-9]+]]:fprb(s32) = COPY $f10_f | ||
; RV32I-NEXT: [[COPY2:%[0-9]+]]:fprb(s32) = COPY $f11_f | ||
; RV32I-NEXT: [[C:%[0-9]+]]:gprb(s32) = G_CONSTANT i32 1 | ||
; RV32I-NEXT: [[AND:%[0-9]+]]:gprb(s32) = G_AND [[COPY]], [[C]] | ||
; RV32I-NEXT: [[SELECT:%[0-9]+]]:fprb(s32) = G_SELECT [[AND]](s32), [[COPY1]], [[COPY2]] | ||
; RV32I-NEXT: $f10_f = COPY [[SELECT]](s32) | ||
; RV32I-NEXT: PseudoRET implicit $f10_f | ||
%3:_(s32) = COPY $x10 | ||
%4:_(s32) = COPY $f10_f | ||
%5:_(s32) = COPY $f11_f | ||
%12:_(s32) = G_CONSTANT i32 1 | ||
%11:_(s32) = G_AND %3, %12 | ||
%10:_(s32) = G_SELECT %11(s32), %4, %5 | ||
$f10_f = COPY %10(s32) | ||
PseudoRET implicit $f10_f | ||
|
||
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. Should we test some cases where one of the operands are from onlyDefinesFP but the other operand can be either? Should we test some cases where the def is used by instructions that onlyDefineFP? |
||
... | ||
--- | ||
name: fp_select_gpr_use_s32 | ||
legalized: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0.entry: | ||
liveins: $x10, $f10_f, $f11_f | ||
|
||
; RV32I-LABEL: name: fp_select_gpr_use_s32 | ||
; RV32I: liveins: $x10, $f10_f, $f11_f | ||
; RV32I-NEXT: {{ $}} | ||
; RV32I-NEXT: [[COPY:%[0-9]+]]:gprb(s32) = COPY $x10 | ||
; RV32I-NEXT: [[COPY1:%[0-9]+]]:fprb(s32) = COPY $f10_f | ||
; RV32I-NEXT: [[COPY2:%[0-9]+]]:fprb(s32) = COPY $f11_f | ||
; RV32I-NEXT: [[C:%[0-9]+]]:gprb(s32) = G_CONSTANT i32 1 | ||
; RV32I-NEXT: [[AND:%[0-9]+]]:gprb(s32) = G_AND [[COPY]], [[C]] | ||
; RV32I-NEXT: [[SELECT:%[0-9]+]]:fprb(s32) = G_SELECT [[AND]](s32), [[COPY1]], [[COPY2]] | ||
; RV32I-NEXT: $x10 = COPY [[SELECT]](s32) | ||
; RV32I-NEXT: PseudoRET implicit $x10 | ||
%3:_(s32) = COPY $x10 | ||
%4:_(s32) = COPY $f10_f | ||
%5:_(s32) = COPY $f11_f | ||
%12:_(s32) = G_CONSTANT i32 1 | ||
%11:_(s32) = G_AND %3, %12 | ||
%10:_(s32) = G_SELECT %11(s32), %4, %5 | ||
$x10 = COPY %10(s32) | ||
PseudoRET implicit $x10 | ||
|
||
... | ||
--- | ||
name: fp_select_gpr_def_s32 | ||
legalized: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0.entry: | ||
liveins: $x10, $x11, $f10_f | ||
|
||
; RV32I-LABEL: name: fp_select_gpr_def_s32 | ||
; RV32I: liveins: $x10, $x11, $f10_f | ||
; RV32I-NEXT: {{ $}} | ||
; RV32I-NEXT: [[COPY:%[0-9]+]]:gprb(s32) = COPY $x10 | ||
; RV32I-NEXT: [[COPY1:%[0-9]+]]:fprb(s32) = COPY $f10_f | ||
; RV32I-NEXT: [[COPY2:%[0-9]+]]:gprb(s32) = COPY $x11 | ||
; RV32I-NEXT: [[C:%[0-9]+]]:gprb(s32) = G_CONSTANT i32 1 | ||
; RV32I-NEXT: [[AND:%[0-9]+]]:gprb(s32) = G_AND [[COPY]], [[C]] | ||
; RV32I-NEXT: [[COPY3:%[0-9]+]]:fprb(s32) = COPY [[COPY2]](s32) | ||
; RV32I-NEXT: [[SELECT:%[0-9]+]]:fprb(s32) = G_SELECT [[AND]](s32), [[COPY1]], [[COPY3]] | ||
; RV32I-NEXT: $f10_f = COPY [[SELECT]](s32) | ||
; RV32I-NEXT: PseudoRET implicit $f10_f | ||
%3:_(s32) = COPY $x10 | ||
%4:_(s32) = COPY $f10_f | ||
%5:_(s32) = COPY $x11 | ||
%12:_(s32) = G_CONSTANT i32 1 | ||
%11:_(s32) = G_AND %3, %12 | ||
%10:_(s32) = G_SELECT %11(s32), %4, %5 | ||
$f10_f = COPY %10(s32) | ||
PseudoRET implicit $f10_f | ||
|
||
... | ||
--- | ||
name: fp_select_only_fpr_use_s32 | ||
legalized: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0.entry: | ||
liveins: $x10, $x11, $x12 | ||
|
||
; RV32I-LABEL: name: fp_select_only_fpr_use_s32 | ||
; RV32I: liveins: $x10, $x11, $x12 | ||
; RV32I-NEXT: {{ $}} | ||
; RV32I-NEXT: [[COPY:%[0-9]+]]:gprb(s32) = COPY $x10 | ||
; RV32I-NEXT: [[COPY1:%[0-9]+]]:gprb(s32) = COPY $x11 | ||
; RV32I-NEXT: [[COPY2:%[0-9]+]]:gprb(s32) = COPY $x12 | ||
; RV32I-NEXT: [[C:%[0-9]+]]:gprb(s32) = G_CONSTANT i32 1 | ||
; RV32I-NEXT: [[AND:%[0-9]+]]:gprb(s32) = G_AND [[COPY]], [[C]] | ||
; RV32I-NEXT: [[SELECT:%[0-9]+]]:gprb(s32) = G_SELECT [[AND]](s32), [[COPY1]], [[COPY2]] | ||
; RV32I-NEXT: $f10_f = COPY [[SELECT]](s32) | ||
; RV32I-NEXT: PseudoRET implicit $f10_f | ||
%3:_(s32) = COPY $x10 | ||
%4:_(s32) = COPY $x11 | ||
%5:_(s32) = COPY $x12 | ||
%12:_(s32) = G_CONSTANT i32 1 | ||
%11:_(s32) = G_AND %3, %12 | ||
%10:_(s32) = G_SELECT %11(s32), %4, %5 | ||
$f10_f = COPY %10(s32) | ||
PseudoRET implicit $f10_f | ||
|
||
... | ||
--- | ||
name: fp_select_only_one_fpr_def_s32 | ||
legalized: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0.entry: | ||
liveins: $x10, $x11, $f10_f | ||
|
||
; RV32I-LABEL: name: fp_select_only_one_fpr_def_s32 | ||
; RV32I: liveins: $x10, $x11, $f10_f | ||
; RV32I-NEXT: {{ $}} | ||
; RV32I-NEXT: [[COPY:%[0-9]+]]:gprb(s32) = COPY $x10 | ||
; RV32I-NEXT: [[COPY1:%[0-9]+]]:fprb(s32) = COPY $f10_f | ||
; RV32I-NEXT: [[COPY2:%[0-9]+]]:gprb(s32) = COPY $x11 | ||
; RV32I-NEXT: [[C:%[0-9]+]]:gprb(s32) = G_CONSTANT i32 1 | ||
; RV32I-NEXT: [[AND:%[0-9]+]]:gprb(s32) = G_AND [[COPY]], [[C]] | ||
; RV32I-NEXT: [[COPY3:%[0-9]+]]:gprb(s32) = COPY [[COPY1]](s32) | ||
; RV32I-NEXT: [[SELECT:%[0-9]+]]:gprb(s32) = G_SELECT [[AND]](s32), [[COPY3]], [[COPY2]] | ||
; RV32I-NEXT: $x10 = COPY [[SELECT]](s32) | ||
; RV32I-NEXT: PseudoRET implicit $x10 | ||
%3:_(s32) = COPY $x10 | ||
%4:_(s32) = COPY $f10_f | ||
%5:_(s32) = COPY $x11 | ||
%12:_(s32) = G_CONSTANT i32 1 | ||
%11:_(s32) = G_AND %3, %12 | ||
%10:_(s32) = G_SELECT %11(s32), %4, %5 | ||
$x10 = COPY %10(s32) | ||
PseudoRET implicit $x10 | ||
|
||
... |
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.
Uh oh!
There was an error while loading. Please reload this page.