Skip to content

Commit ca13555

Browse files
committed
[RISCV] Pre-commit tests for D121833. NFC
1 parent 7d426a3 commit ca13555

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

llvm/test/CodeGen/RISCV/alu16.ll

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,55 @@ define i16 @sll(i16 %a, i16 %b) nounwind {
209209
ret i16 %1
210210
}
211211

212+
; Test the pattern we get from C integer promotion.
213+
define void @sll_ext(i16 %a, i32 signext %b, i16* %p) nounwind {
214+
; RV32I-LABEL: sll_ext:
215+
; RV32I: # %bb.0:
216+
; RV32I-NEXT: slli a0, a0, 16
217+
; RV32I-NEXT: srli a0, a0, 16
218+
; RV32I-NEXT: sll a0, a0, a1
219+
; RV32I-NEXT: sh a0, 0(a2)
220+
; RV32I-NEXT: ret
221+
;
222+
; RV64I-LABEL: sll_ext:
223+
; RV64I: # %bb.0:
224+
; RV64I-NEXT: slli a0, a0, 48
225+
; RV64I-NEXT: srli a0, a0, 48
226+
; RV64I-NEXT: sllw a0, a0, a1
227+
; RV64I-NEXT: sh a0, 0(a2)
228+
; RV64I-NEXT: ret
229+
%1 = zext i16 %a to i32
230+
%2 = shl i32 %1, %b
231+
%3 = trunc i32 %2 to i16
232+
store i16 %3, i16* %p
233+
ret void
234+
}
235+
236+
; Test the pattern we get from C integer promotion. This time with poison
237+
; generating flags.
238+
define void @sll_ext_drop_poison(i16 %a, i32 signext %b, i16* %p) nounwind {
239+
; RV32I-LABEL: sll_ext_drop_poison:
240+
; RV32I: # %bb.0:
241+
; RV32I-NEXT: slli a0, a0, 16
242+
; RV32I-NEXT: srli a0, a0, 16
243+
; RV32I-NEXT: sll a0, a0, a1
244+
; RV32I-NEXT: sh a0, 0(a2)
245+
; RV32I-NEXT: ret
246+
;
247+
; RV64I-LABEL: sll_ext_drop_poison:
248+
; RV64I: # %bb.0:
249+
; RV64I-NEXT: slli a0, a0, 48
250+
; RV64I-NEXT: srli a0, a0, 48
251+
; RV64I-NEXT: sllw a0, a0, a1
252+
; RV64I-NEXT: sh a0, 0(a2)
253+
; RV64I-NEXT: ret
254+
%1 = zext i16 %a to i32
255+
%2 = shl nuw nsw i32 %1, %b
256+
%3 = trunc i32 %2 to i16
257+
store i16 %3, i16* %p
258+
ret void
259+
}
260+
212261
define i16 @slt(i16 %a, i16 %b) nounwind {
213262
; RV32I-LABEL: slt:
214263
; RV32I: # %bb.0:

llvm/test/CodeGen/RISCV/alu8.ll

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,51 @@ define i8 @sll(i8 %a, i8 %b) nounwind {
207207
ret i8 %1
208208
}
209209

210+
; Test the pattern we get from C integer promotion.
211+
define void @sll_ext(i8 %a, i32 signext %b, i8* %p) nounwind {
212+
; RV32I-LABEL: sll_ext:
213+
; RV32I: # %bb.0:
214+
; RV32I-NEXT: andi a0, a0, 255
215+
; RV32I-NEXT: sll a0, a0, a1
216+
; RV32I-NEXT: sb a0, 0(a2)
217+
; RV32I-NEXT: ret
218+
;
219+
; RV64I-LABEL: sll_ext:
220+
; RV64I: # %bb.0:
221+
; RV64I-NEXT: andi a0, a0, 255
222+
; RV64I-NEXT: sllw a0, a0, a1
223+
; RV64I-NEXT: sb a0, 0(a2)
224+
; RV64I-NEXT: ret
225+
%1 = zext i8 %a to i32
226+
%2 = shl i32 %1, %b
227+
%3 = trunc i32 %2 to i8
228+
store i8 %3, i8* %p
229+
ret void
230+
}
231+
232+
; Test the pattern we get from C integer promotion. This time with poison
233+
; generating flags.
234+
define void @sll_ext_drop_poison(i8 %a, i32 signext %b, i8* %p) nounwind {
235+
; RV32I-LABEL: sll_ext_drop_poison:
236+
; RV32I: # %bb.0:
237+
; RV32I-NEXT: andi a0, a0, 255
238+
; RV32I-NEXT: sll a0, a0, a1
239+
; RV32I-NEXT: sb a0, 0(a2)
240+
; RV32I-NEXT: ret
241+
;
242+
; RV64I-LABEL: sll_ext_drop_poison:
243+
; RV64I: # %bb.0:
244+
; RV64I-NEXT: andi a0, a0, 255
245+
; RV64I-NEXT: sllw a0, a0, a1
246+
; RV64I-NEXT: sb a0, 0(a2)
247+
; RV64I-NEXT: ret
248+
%1 = zext i8 %a to i32
249+
%2 = shl nuw nsw i32 %1, %b
250+
%3 = trunc i32 %2 to i8
251+
store i8 %3, i8* %p
252+
ret void
253+
}
254+
210255
define i8 @slt(i8 %a, i8 %b) nounwind {
211256
; RV32I-LABEL: slt:
212257
; RV32I: # %bb.0:

0 commit comments

Comments
 (0)