Skip to content

Commit 4d5c0f4

Browse files
committed
[RISCV] Pre-commit
1 parent 972ecc3 commit 4d5c0f4

File tree

2 files changed

+156
-0
lines changed

2 files changed

+156
-0
lines changed

llvm/test/CodeGen/RISCV/rv32xandesperf.ll

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
; RUN: llc -O0 -mtriple=riscv32 -mattr=+xandesperf -verify-machineinstrs < %s \
33
; RUN: | FileCheck %s
44

5+
; NDS.BFOZ
6+
7+
; MSB >= LSB
8+
59
define i32 @bfoz_from_and_i32(i32 %x) {
610
; CHECK-LABEL: bfoz_from_and_i32:
711
; CHECK: # %bb.0:
@@ -70,6 +74,58 @@ define i64 @bfoz_from_lshr_and_i64(i64 %x) {
7074
ret i64 %shifted
7175
}
7276

77+
; MSB = 0
78+
79+
define i32 @bfoz_from_and_shl_with_msb_zero_i32(i32 %x) {
80+
; CHECK-LABEL: bfoz_from_and_shl_with_msb_zero_i32:
81+
; CHECK: # %bb.0:
82+
; CHECK-NEXT: slli a0, a0, 31
83+
; CHECK-NEXT: srli a0, a0, 16
84+
; CHECK-NEXT: ret
85+
%shifted = shl i32 %x, 15
86+
%masked = and i32 %shifted, 32768
87+
ret i32 %masked
88+
}
89+
90+
define i32 @bfoz_from_lshr_shl_with_msb_zero_i32(i32 %x) {
91+
; CHECK-LABEL: bfoz_from_lshr_shl_with_msb_zero_i32:
92+
; CHECK: # %bb.0:
93+
; CHECK-NEXT: slli a0, a0, 31
94+
; CHECK-NEXT: srli a0, a0, 13
95+
; CHECK-NEXT: ret
96+
%shl = shl i32 %x, 31
97+
%lshr = lshr i32 %shl, 13
98+
ret i32 %lshr
99+
}
100+
101+
; MSB < LSB
102+
103+
define i32 @bfoz_from_and_shl_i32(i32 %x) {
104+
; CHECK-LABEL: bfoz_from_and_shl_i32:
105+
; CHECK: # %bb.0:
106+
; CHECK-NEXT: slli a0, a0, 20
107+
; CHECK-NEXT: srli a0, a0, 8
108+
; CHECK-NEXT: ret
109+
%shifted = shl i32 %x, 12
110+
%masked = and i32 %shifted, 16773120
111+
ret i32 %masked
112+
}
113+
114+
define i32 @bfoz_from_lshr_shl_i32(i32 %x) {
115+
; CHECK-LABEL: bfoz_from_lshr_shl_i32:
116+
; CHECK: # %bb.0:
117+
; CHECK-NEXT: slli a0, a0, 26
118+
; CHECK-NEXT: srli a0, a0, 7
119+
; CHECK-NEXT: ret
120+
%shl = shl i32 %x, 26
121+
%lshr = lshr i32 %shl, 7
122+
ret i32 %lshr
123+
}
124+
125+
; NDS.BFOS
126+
127+
; MSB >= LSB
128+
73129
define i32 @bfos_from_ashr_shl_i32(i32 %x) {
74130
; CHECK-LABEL: bfos_from_ashr_shl_i32:
75131
; CHECK: # %bb.0:

llvm/test/CodeGen/RISCV/rv64xandesperf.ll

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
; RUN: llc -mtriple=riscv64 -mattr=+xandesperf -verify-machineinstrs < %s \
33
; RUN: | FileCheck %s
44

5+
; NDS.BFOZ
6+
7+
; MSB >= LSB
8+
59
define i32 @bfoz_from_and_i32(i32 %x) {
610
; CHECK-LABEL: bfoz_from_and_i32:
711
; CHECK: # %bb.0:
@@ -60,6 +64,102 @@ define i64 @bfoz_from_lshr_and_i64(i64 %x) {
6064
ret i64 %shifted
6165
}
6266

67+
; MSB = 0
68+
69+
define i32 @bfoz_from_and_shl_with_msb_zero_i32(i32 %x) {
70+
; CHECK-LABEL: bfoz_from_and_shl_with_msb_zero_i32:
71+
; CHECK: # %bb.0:
72+
; CHECK-NEXT: slli a0, a0, 63
73+
; CHECK-NEXT: srli a0, a0, 48
74+
; CHECK-NEXT: ret
75+
%shifted = shl i32 %x, 15
76+
%masked = and i32 %shifted, 32768
77+
ret i32 %masked
78+
}
79+
80+
define i64 @bfoz_from_and_shl_with_msb_zero_i64(i64 %x) {
81+
; CHECK-LABEL: bfoz_from_and_shl_with_msb_zero_i64:
82+
; CHECK: # %bb.0:
83+
; CHECK-NEXT: slli a0, a0, 63
84+
; CHECK-NEXT: srli a0, a0, 15
85+
; CHECK-NEXT: ret
86+
%shifted = shl i64 %x, 48
87+
%masked = and i64 %shifted, 281474976710656
88+
ret i64 %masked
89+
}
90+
91+
define i32 @bfoz_from_lshr_shl_with_msb_zero_i32(i32 %x) {
92+
; CHECK-LABEL: bfoz_from_lshr_shl_with_msb_zero_i32:
93+
; CHECK: # %bb.0:
94+
; CHECK-NEXT: slli a0, a0, 63
95+
; CHECK-NEXT: srli a0, a0, 45
96+
; CHECK-NEXT: ret
97+
%shl = shl i32 %x, 31
98+
%lshr = lshr i32 %shl, 13
99+
ret i32 %lshr
100+
}
101+
102+
define i64 @bfoz_from_lshr_shl_with_msb_zero_i64(i64 %x) {
103+
; CHECK-LABEL: bfoz_from_lshr_shl_with_msb_zero_i64:
104+
; CHECK: # %bb.0:
105+
; CHECK-NEXT: slli a0, a0, 63
106+
; CHECK-NEXT: srli a0, a0, 19
107+
; CHECK-NEXT: ret
108+
%shl = shl i64 %x, 63
109+
%lshr = lshr i64 %shl, 19
110+
ret i64 %lshr
111+
}
112+
113+
; MSB < LSB
114+
115+
define i32 @bfoz_from_and_shl_i32(i32 %x) {
116+
; CHECK-LABEL: bfoz_from_and_shl_i32:
117+
; CHECK: # %bb.0:
118+
; CHECK-NEXT: slli a0, a0, 52
119+
; CHECK-NEXT: srli a0, a0, 40
120+
; CHECK-NEXT: ret
121+
%shifted = shl i32 %x, 12
122+
%masked = and i32 %shifted, 16773120
123+
ret i32 %masked
124+
}
125+
126+
define i64 @bfoz_from_and_shl_i64(i64 %x) {
127+
; CHECK-LABEL: bfoz_from_and_shl_i64:
128+
; CHECK: # %bb.0:
129+
; CHECK-NEXT: slli a0, a0, 52
130+
; CHECK-NEXT: srli a0, a0, 28
131+
; CHECK-NEXT: ret
132+
%shifted = shl i64 %x, 24
133+
%masked = and i64 %shifted, 68702699520
134+
ret i64 %masked
135+
}
136+
137+
define i32 @bfoz_from_lshr_shl_i32(i32 %x) {
138+
; CHECK-LABEL: bfoz_from_lshr_shl_i32:
139+
; CHECK: # %bb.0:
140+
; CHECK-NEXT: slli a0, a0, 58
141+
; CHECK-NEXT: srli a0, a0, 39
142+
; CHECK-NEXT: ret
143+
%shl = shl i32 %x, 26
144+
%lshr = lshr i32 %shl, 7
145+
ret i32 %lshr
146+
}
147+
148+
define i64 @bfoz_from_lshr_shl_i64(i64 %x) {
149+
; CHECK-LABEL: bfoz_from_lshr_shl_i64:
150+
; CHECK: # %bb.0:
151+
; CHECK-NEXT: slli a0, a0, 40
152+
; CHECK-NEXT: srli a0, a0, 15
153+
; CHECK-NEXT: ret
154+
%shl = shl i64 %x, 40
155+
%lshr = lshr i64 %shl, 15
156+
ret i64 %lshr
157+
}
158+
159+
; NDS.BFOS
160+
161+
; MSB >= LSB
162+
63163
define i32 @bfos_from_ashr_shl_i32(i32 %x) {
64164
; CHECK-LABEL: bfos_from_ashr_shl_i32:
65165
; CHECK: # %bb.0:

0 commit comments

Comments
 (0)