-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[LoongArch] Implement COPY instruction between CFRs #69300
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
5 commits
Select commit
Hold shift + click to select a range
e001613
[LoongArch] Implement COPY instruction between CFRs
wangleiat bb5b25c
Update llvm/lib/Target/LoongArch/LoongArchExpandPseudoInsts.cpp
wangleiat 63dfee9
Update llvm/lib/Target/LoongArch/LoongArchFloat32InstrInfo.td
wangleiat f322789
Update llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp
wangleiat aba3a1c
Update LoongArchFloat32InstrInfo.td
wangleiat 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
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,34 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3 | ||
# RUN: llc --mtriple=loongarch64 --mattr=+d %s -o - | FileCheck %s | ||
|
||
## Check the PseudoCopyCFR instruction expand. | ||
|
||
--- | | ||
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" | ||
target triple = "loongarch64" | ||
|
||
define void @test() { | ||
; CHECK-LABEL: test: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: fcmp.caf.s $fcc1, $fa0, $fa0 | ||
; CHECK-NEXT: bceqz $fcc0, .LBB0_2 | ||
; CHECK-NEXT: # %bb.1: | ||
; CHECK-NEXT: fcmp.cueq.s $fcc1, $fa0, $fa0 | ||
; CHECK-NEXT: .LBB0_2: | ||
; CHECK-NEXT: movcf2gr $a0, $fcc1 | ||
; CHECK-NEXT: ret | ||
ret void | ||
} | ||
... | ||
--- | ||
name: test | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0: | ||
liveins: $fcc0 | ||
|
||
$fcc1 = COPY $fcc0 | ||
$r4 = COPY $fcc1 | ||
PseudoRET implicit killed $r4 | ||
|
||
... |
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,26 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py | ||
# RUN: llc --mtriple=loongarch64 --mattr=+d --stop-after=postrapseudos %s \ | ||
# RUN: -o - | FileCheck %s | ||
|
||
## Check the COPY instruction between CFRs. | ||
## A pseudo (PseudoCopyCFR) is generated after postrapseudos pass. | ||
|
||
... | ||
--- | ||
name: test | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0.entry: | ||
liveins: $fcc0 | ||
|
||
; CHECK-LABEL: name: test | ||
; CHECK: liveins: $fcc0 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: $fcc1 = PseudoCopyCFR $fcc0 | ||
; CHECK-NEXT: $r4 = MOVCF2GR killed $fcc1 | ||
; CHECK-NEXT: PseudoRET implicit killed $r4 | ||
$fcc1 = COPY $fcc0 | ||
$r4 = COPY $fcc1 | ||
PseudoRET implicit killed $r4 | ||
|
||
... |
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
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 know if
movgr2cf $dst, $zero
would be better micro-architecture-wise, perhaps you know better?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.
FWIW GCC uses
movgr2cf %0,$r0
for zeroing a fcc. But I'm not sure which is micro-architecture-wise better too.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.
Some tests show
movgr2cf
is slower than other insns, but not sure aboutfcmp.caf.s
.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.
Phew:
So
fcmp.caf.s
is indeed better...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.
Then maybe documenting this finding would be beneficial (and GCC could use some micro-optimization too)!
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.
(And you could inform the HW team to add short-circuiting for
movgr2cf *, $zero
so it doesn't naïvely goes to the ALU unconditionally (which I expect to be the reason of slowdown) in that case. So we can have the semantically-equivalent patterns execute at the same speed without surprises on future models...)