-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[RISCV][GlobalISel] Zbkb support for G_BSWAP #77050
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,9 @@ | |
# RUN: llc -mtriple=riscv32 -run-pass=legalizer %s -o - \ | ||
# RUN: | FileCheck %s --check-prefix=RV32I | ||
# RUN: llc -mtriple=riscv32 -mattr=+zbb -run-pass=legalizer %s -o - \ | ||
# RUN: | FileCheck %s --check-prefix=RV32ZBB | ||
# RUN: | FileCheck %s --check-prefix=RV32ZBB_OR_RV32ZBKB | ||
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. I think these can be simplified to CHECK? 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. We are checking generated code in two scenarios: when zbb or zbkb is present and when it's not. So I think having these descriptions in the prefix is good. |
||
# RUN: llc -mtriple=riscv32 -mattr=+zbkb -run-pass=legalizer %s -o - \ | ||
# RUN: | FileCheck %s --check-prefix=RV32ZBB_OR_RV32ZBKB | ||
|
||
--- | ||
name: bswap_i16 | ||
|
@@ -23,16 +25,16 @@ body: | | |
; RV32I-NEXT: $x10 = COPY [[AND]](s32) | ||
; RV32I-NEXT: PseudoRET implicit $x10 | ||
; | ||
; RV32ZBB-LABEL: name: bswap_i16 | ||
; RV32ZBB: liveins: $x10 | ||
; RV32ZBB-NEXT: {{ $}} | ||
; RV32ZBB-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 | ||
; RV32ZBB-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16 | ||
; RV32ZBB-NEXT: [[BSWAP:%[0-9]+]]:_(s32) = G_BSWAP [[ASSERT_ZEXT]] | ||
; RV32ZBB-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 | ||
; RV32ZBB-NEXT: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[BSWAP]], [[C]](s32) | ||
; RV32ZBB-NEXT: $x10 = COPY [[LSHR]](s32) | ||
; RV32ZBB-NEXT: PseudoRET implicit $x10 | ||
; RV32ZBB_OR_RV32ZBKB-LABEL: name: bswap_i16 | ||
; RV32ZBB_OR_RV32ZBKB: liveins: $x10 | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: {{ $}} | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16 | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: [[BSWAP:%[0-9]+]]:_(s32) = G_BSWAP [[ASSERT_ZEXT]] | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[BSWAP]], [[C]](s32) | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: $x10 = COPY [[LSHR]](s32) | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: PseudoRET implicit $x10 | ||
%0:_(s32) = COPY $x10 | ||
%1:_(s32) = G_ASSERT_ZEXT %0, 16 | ||
%2:_(s16) = G_TRUNC %1(s32) | ||
|
@@ -65,13 +67,13 @@ body: | | |
; RV32I-NEXT: $x10 = COPY [[OR2]](s32) | ||
; RV32I-NEXT: PseudoRET implicit $x10 | ||
; | ||
; RV32ZBB-LABEL: name: bswap_i32 | ||
; RV32ZBB: liveins: $x10 | ||
; RV32ZBB-NEXT: {{ $}} | ||
; RV32ZBB-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 | ||
; RV32ZBB-NEXT: [[BSWAP:%[0-9]+]]:_(s32) = G_BSWAP [[COPY]] | ||
; RV32ZBB-NEXT: $x10 = COPY [[BSWAP]](s32) | ||
; RV32ZBB-NEXT: PseudoRET implicit $x10 | ||
; RV32ZBB_OR_RV32ZBKB-LABEL: name: bswap_i32 | ||
; RV32ZBB_OR_RV32ZBKB: liveins: $x10 | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: {{ $}} | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: [[BSWAP:%[0-9]+]]:_(s32) = G_BSWAP [[COPY]] | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: $x10 = COPY [[BSWAP]](s32) | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: PseudoRET implicit $x10 | ||
%0:_(s32) = COPY $x10 | ||
%1:_(s32) = G_BSWAP %0 | ||
$x10 = COPY %1(s32) | ||
|
@@ -115,16 +117,16 @@ body: | | |
; RV32I-NEXT: $x11 = COPY [[OR5]](s32) | ||
; RV32I-NEXT: PseudoRET implicit $x10, implicit $x11 | ||
; | ||
; RV32ZBB-LABEL: name: bswap_i64 | ||
; RV32ZBB: liveins: $x10, $x11 | ||
; RV32ZBB-NEXT: {{ $}} | ||
; RV32ZBB-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 | ||
; RV32ZBB-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11 | ||
; RV32ZBB-NEXT: [[BSWAP:%[0-9]+]]:_(s32) = G_BSWAP [[COPY1]] | ||
; RV32ZBB-NEXT: [[BSWAP1:%[0-9]+]]:_(s32) = G_BSWAP [[COPY]] | ||
; RV32ZBB-NEXT: $x10 = COPY [[BSWAP]](s32) | ||
; RV32ZBB-NEXT: $x11 = COPY [[BSWAP1]](s32) | ||
; RV32ZBB-NEXT: PseudoRET implicit $x10, implicit $x11 | ||
; RV32ZBB_OR_RV32ZBKB-LABEL: name: bswap_i64 | ||
; RV32ZBB_OR_RV32ZBKB: liveins: $x10, $x11 | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: {{ $}} | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10 | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11 | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: [[BSWAP:%[0-9]+]]:_(s32) = G_BSWAP [[COPY1]] | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: [[BSWAP1:%[0-9]+]]:_(s32) = G_BSWAP [[COPY]] | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: $x10 = COPY [[BSWAP]](s32) | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: $x11 = COPY [[BSWAP1]](s32) | ||
; RV32ZBB_OR_RV32ZBKB-NEXT: PseudoRET implicit $x10, implicit $x11 | ||
%0:_(s32) = COPY $x10 | ||
%1:_(s32) = COPY $x11 | ||
%2:_(s64) = G_MERGE_VALUES %0(s32), %1(s32) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,9 @@ | |
# RUN: llc -mtriple=riscv64 -run-pass=legalizer %s -o - \ | ||
# RUN: | FileCheck %s --check-prefix=RV64I | ||
# RUN: llc -mtriple=riscv64 -mattr=+zbb -run-pass=legalizer %s -o - \ | ||
# RUN: | FileCheck %s --check-prefix=RV64ZBB | ||
# RUN: | FileCheck %s --check-prefix=RV64ZBB_OR_RV64ZBKB | ||
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. I think these can be simplified to CHECK? |
||
# RUN: llc -mtriple=riscv64 -mattr=+zbkb -run-pass=legalizer %s -o - \ | ||
# RUN: | FileCheck %s --check-prefix=RV64ZBB_OR_RV64ZBKB | ||
|
||
--- | ||
name: bswap_i16 | ||
|
@@ -27,16 +29,16 @@ body: | | |
; RV64I-NEXT: $x10 = COPY [[AND]](s64) | ||
; RV64I-NEXT: PseudoRET implicit $x10 | ||
; | ||
; RV64ZBB-LABEL: name: bswap_i16 | ||
; RV64ZBB: liveins: $x10 | ||
; RV64ZBB-NEXT: {{ $}} | ||
; RV64ZBB-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 | ||
; RV64ZBB-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s64) = G_ASSERT_ZEXT [[COPY]], 16 | ||
; RV64ZBB-NEXT: [[BSWAP:%[0-9]+]]:_(s64) = G_BSWAP [[ASSERT_ZEXT]] | ||
; RV64ZBB-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 48 | ||
; RV64ZBB-NEXT: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[BSWAP]], [[C]](s64) | ||
; RV64ZBB-NEXT: $x10 = COPY [[LSHR]](s64) | ||
; RV64ZBB-NEXT: PseudoRET implicit $x10 | ||
; RV64ZBB_OR_RV64ZBKB-LABEL: name: bswap_i16 | ||
; RV64ZBB_OR_RV64ZBKB: liveins: $x10 | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: {{ $}} | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s64) = G_ASSERT_ZEXT [[COPY]], 16 | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: [[BSWAP:%[0-9]+]]:_(s64) = G_BSWAP [[ASSERT_ZEXT]] | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 48 | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[BSWAP]], [[C]](s64) | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: $x10 = COPY [[LSHR]](s64) | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: PseudoRET implicit $x10 | ||
%0:_(s64) = COPY $x10 | ||
%1:_(s64) = G_ASSERT_ZEXT %0, 16 | ||
%2:_(s16) = G_TRUNC %1(s64) | ||
|
@@ -74,16 +76,16 @@ body: | | |
; RV64I-NEXT: $x10 = COPY [[ZEXT]](s64) | ||
; RV64I-NEXT: PseudoRET implicit $x10 | ||
; | ||
; RV64ZBB-LABEL: name: bswap_i32 | ||
; RV64ZBB: liveins: $x10 | ||
; RV64ZBB-NEXT: {{ $}} | ||
; RV64ZBB-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 | ||
; RV64ZBB-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s64) = G_ASSERT_ZEXT [[COPY]], 32 | ||
; RV64ZBB-NEXT: [[BSWAP:%[0-9]+]]:_(s64) = G_BSWAP [[ASSERT_ZEXT]] | ||
; RV64ZBB-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32 | ||
; RV64ZBB-NEXT: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[BSWAP]], [[C]](s64) | ||
; RV64ZBB-NEXT: $x10 = COPY [[LSHR]](s64) | ||
; RV64ZBB-NEXT: PseudoRET implicit $x10 | ||
; RV64ZBB_OR_RV64ZBKB-LABEL: name: bswap_i32 | ||
; RV64ZBB_OR_RV64ZBKB: liveins: $x10 | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: {{ $}} | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s64) = G_ASSERT_ZEXT [[COPY]], 32 | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: [[BSWAP:%[0-9]+]]:_(s64) = G_BSWAP [[ASSERT_ZEXT]] | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32 | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[BSWAP]], [[C]](s64) | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: $x10 = COPY [[LSHR]](s64) | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: PseudoRET implicit $x10 | ||
%0:_(s64) = COPY $x10 | ||
%1:_(s64) = G_ASSERT_ZEXT %0, 32 | ||
%2:_(s32) = G_TRUNC %1(s64) | ||
|
@@ -132,13 +134,13 @@ body: | | |
; RV64I-NEXT: $x10 = COPY [[OR6]](s64) | ||
; RV64I-NEXT: PseudoRET implicit $x10 | ||
; | ||
; RV64ZBB-LABEL: name: bswap_i64 | ||
; RV64ZBB: liveins: $x10 | ||
; RV64ZBB-NEXT: {{ $}} | ||
; RV64ZBB-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 | ||
; RV64ZBB-NEXT: [[BSWAP:%[0-9]+]]:_(s64) = G_BSWAP [[COPY]] | ||
; RV64ZBB-NEXT: $x10 = COPY [[BSWAP]](s64) | ||
; RV64ZBB-NEXT: PseudoRET implicit $x10 | ||
; RV64ZBB_OR_RV64ZBKB-LABEL: name: bswap_i64 | ||
; RV64ZBB_OR_RV64ZBKB: liveins: $x10 | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: {{ $}} | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: [[BSWAP:%[0-9]+]]:_(s64) = G_BSWAP [[COPY]] | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: $x10 = COPY [[BSWAP]](s64) | ||
; RV64ZBB_OR_RV64ZBKB-NEXT: PseudoRET implicit $x10 | ||
%0:_(s64) = COPY $x10 | ||
%1:_(s64) = G_BSWAP %0 | ||
$x10 = COPY %1(s64) | ||
|
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.
Should we change the prefix here and in 64-bit version also to
RV...ZBB_OR_ZBKB
?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.
Sure. Or we could just use the default
CHECK
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.
changed to "CHECK"