forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GISel][RISCV] Implement selectShiftMask. (llvm#77572)
Implement `selectShiftMask` in `GlobalISel`.
- Loading branch information
1 parent
aef7b74
commit 75a25c1
Showing
4 changed files
with
501 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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 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
190 changes: 190 additions & 0 deletions
190
llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/shift-rv32.mir
This file contains 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,190 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4 | ||
# RUN: llc -mtriple=riscv32 -run-pass=instruction-select \ | ||
# RUN: -simplify-mir -verify-machineinstrs %s -o - | FileCheck %s | ||
|
||
# This 32-bit version doesn't have tests for zext, because there is no legal type to zext from. | ||
--- | ||
name: shl | ||
legalized: true | ||
regBankSelected: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0: | ||
liveins: $x10, $x11 | ||
; CHECK-LABEL: name: shl | ||
; CHECK: liveins: $x10, $x11 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 | ||
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 | ||
; CHECK-NEXT: [[SLL:%[0-9]+]]:gpr = SLL [[COPY]], [[COPY1]] | ||
; CHECK-NEXT: $x10 = COPY [[SLL]] | ||
; CHECK-NEXT: PseudoRET implicit $x10 | ||
%0:gprb(s32) = COPY $x10 | ||
%1:gprb(s32) = COPY $x11 | ||
%3:gprb(s32) = G_SHL %0, %1 | ||
$x10 = COPY %3(s32) | ||
PseudoRET implicit $x10 | ||
... | ||
|
||
--- | ||
name: shl_and | ||
legalized: true | ||
regBankSelected: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0: | ||
liveins: $x10, $x11 | ||
; CHECK-LABEL: name: shl_and | ||
; CHECK: liveins: $x10, $x11 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 | ||
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 | ||
; CHECK-NEXT: [[SLL:%[0-9]+]]:gpr = SLL [[COPY]], [[COPY1]] | ||
; CHECK-NEXT: $x10 = COPY [[SLL]] | ||
; CHECK-NEXT: PseudoRET implicit $x10 | ||
%0:gprb(s32) = COPY $x10 | ||
%1:gprb(s32) = COPY $x11 | ||
%2:gprb(s32) = G_CONSTANT i32 31 | ||
%3:gprb(s32) = G_AND %1, %2 | ||
%4:gprb(s32) = G_SHL %0, %3(s32) | ||
$x10 = COPY %4(s32) | ||
PseudoRET implicit $x10 | ||
... | ||
|
||
--- | ||
name: shl_and_with_simplified_mask | ||
legalized: true | ||
regBankSelected: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0: | ||
liveins: $x10, $x11 | ||
; CHECK-LABEL: name: shl_and_with_simplified_mask | ||
; CHECK: liveins: $x10, $x11 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 | ||
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 | ||
; CHECK-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[COPY1]], 31 | ||
; CHECK-NEXT: [[SLL:%[0-9]+]]:gpr = SLL [[COPY]], [[ANDI]] | ||
; CHECK-NEXT: $x10 = COPY [[SLL]] | ||
; CHECK-NEXT: PseudoRET implicit $x10 | ||
%0:gprb(s32) = COPY $x10 | ||
%1:gprb(s32) = COPY $x11 | ||
%2:gprb(s32) = G_CONSTANT i32 31 | ||
%3:gprb(s32) = G_AND %1, %2 | ||
%4:gprb(s32) = G_CONSTANT i32 31 | ||
%5:gprb(s32) = G_AND %3, %4 | ||
%6:gprb(s32) = G_SHL %0, %5(s32) | ||
$x10 = COPY %6(s32) | ||
PseudoRET implicit $x10 | ||
... | ||
|
||
--- | ||
name: shl_add | ||
legalized: true | ||
regBankSelected: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0: | ||
liveins: $x10, $x11 | ||
; CHECK-LABEL: name: shl_add | ||
; CHECK: liveins: $x10, $x11 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 | ||
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 | ||
; CHECK-NEXT: [[SLL:%[0-9]+]]:gpr = SLL [[COPY]], [[COPY1]] | ||
; CHECK-NEXT: $x10 = COPY [[SLL]] | ||
; CHECK-NEXT: PseudoRET implicit $x10 | ||
%0:gprb(s32) = COPY $x10 | ||
%1:gprb(s32) = COPY $x11 | ||
%2:gprb(s32) = G_CONSTANT i32 32 | ||
%3:gprb(s32) = G_ADD %1, %2 | ||
%4:gprb(s32) = G_SHL %0, %3(s32) | ||
$x10 = COPY %4(s32) | ||
PseudoRET implicit $x10 | ||
... | ||
|
||
--- | ||
name: shl_sub | ||
legalized: true | ||
regBankSelected: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0: | ||
liveins: $x10, $x11 | ||
; CHECK-LABEL: name: shl_sub | ||
; CHECK: liveins: $x10, $x11 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 | ||
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 | ||
; CHECK-NEXT: [[SUB:%[0-9]+]]:gpr = SUB $x0, [[COPY1]] | ||
; CHECK-NEXT: [[SLL:%[0-9]+]]:gpr = SLL [[COPY]], [[SUB]] | ||
; CHECK-NEXT: $x10 = COPY [[SLL]] | ||
; CHECK-NEXT: PseudoRET implicit $x10 | ||
%0:gprb(s32) = COPY $x10 | ||
%1:gprb(s32) = COPY $x11 | ||
%2:gprb(s32) = G_CONSTANT i32 32 | ||
%3:gprb(s32) = G_SUB %2, %1 | ||
%4:gprb(s32) = G_SHL %0, %3(s32) | ||
$x10 = COPY %4(s32) | ||
PseudoRET implicit $x10 | ||
... | ||
|
||
--- | ||
name: shl_bitwise_not | ||
legalized: true | ||
regBankSelected: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0: | ||
liveins: $x10, $x11 | ||
; CHECK-LABEL: name: shl_bitwise_not | ||
; CHECK: liveins: $x10, $x11 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 | ||
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 | ||
; CHECK-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[COPY1]], -1 | ||
; CHECK-NEXT: [[SLL:%[0-9]+]]:gpr = SLL [[COPY]], [[XORI]] | ||
; CHECK-NEXT: $x10 = COPY [[SLL]] | ||
; CHECK-NEXT: PseudoRET implicit $x10 | ||
%0:gprb(s32) = COPY $x10 | ||
%1:gprb(s32) = COPY $x11 | ||
%2:gprb(s32) = G_CONSTANT i32 -1 | ||
%3:gprb(s32) = G_SUB %2, %1 | ||
%4:gprb(s32) = G_SHL %0, %3(s32) | ||
$x10 = COPY %4(s32) | ||
PseudoRET implicit $x10 | ||
... | ||
|
||
--- | ||
name: shl_bitwise_not_2 | ||
legalized: true | ||
regBankSelected: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0: | ||
liveins: $x10, $x11 | ||
; CHECK-LABEL: name: shl_bitwise_not_2 | ||
; CHECK: liveins: $x10, $x11 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 | ||
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 | ||
; CHECK-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[COPY1]], -1 | ||
; CHECK-NEXT: [[SLL:%[0-9]+]]:gpr = SLL [[COPY]], [[XORI]] | ||
; CHECK-NEXT: $x10 = COPY [[SLL]] | ||
; CHECK-NEXT: PseudoRET implicit $x10 | ||
%0:gprb(s32) = COPY $x10 | ||
%1:gprb(s32) = COPY $x11 | ||
%2:gprb(s32) = G_CONSTANT i32 31 | ||
%3:gprb(s32) = G_SUB %2, %1 | ||
%4:gprb(s32) = G_SHL %0, %3(s32) | ||
$x10 = COPY %4(s32) | ||
PseudoRET implicit $x10 | ||
... |
Oops, something went wrong.