1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2 ; RUN: llc -mtriple=amdgcn -mcpu=gfx950 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX950 %s
3 define amdgpu_kernel void @v_ashr_pk_i8_i32(ptr addrspace(1) %out, i32 %src0, i32 %src1, i32 %src2) #0 {
4 ; GFX950-LABEL: v_ashr_pk_i8_i32:
6 ; GFX950-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x2c
7 ; GFX950-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x24
8 ; GFX950-NEXT: v_mov_b32_e32 v1, 0xffffff80
9 ; GFX950-NEXT: v_mov_b32_e32 v2, 0x7f
10 ; GFX950-NEXT: v_mov_b32_e32 v0, 0
11 ; GFX950-NEXT: s_waitcnt lgkmcnt(0)
12 ; GFX950-NEXT: s_ashr_i32 s1, s1, s2
13 ; GFX950-NEXT: s_ashr_i32 s0, s0, s2
14 ; GFX950-NEXT: v_med3_i32 v3, s0, v1, v2
15 ; GFX950-NEXT: v_med3_i32 v1, s1, v1, v2
16 ; GFX950-NEXT: v_lshlrev_b32_e32 v1, 8, v1
17 ; GFX950-NEXT: v_or_b32_sdwa v1, v3, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:BYTE_0 src1_sel:DWORD
18 ; GFX950-NEXT: global_store_short v0, v1, s[6:7]
19 ; GFX950-NEXT: s_endpgm
20 %insert.0 = insertelement <2 x i32> poison, i32 %src0, i64 0
21 %build_vector = insertelement <2 x i32> %insert.0, i32 %src1, i64 1
22 %src2.clamp = and i32 %src2, 31
23 %insert.1 = insertelement <2 x i32> poison, i32 %src2.clamp, i64 0
24 %src2.broadcast = shufflevector <2 x i32> %insert.1, <2 x i32> poison, <2 x i32> zeroinitializer
25 %ashr = ashr <2 x i32> %build_vector, %src2.broadcast
26 %sat.low = tail call <2 x i32> @llvm.smax.v2i32(<2 x i32> %ashr, <2 x i32> <i32 -128, i32 -128>)
27 %sat.hi = tail call <2 x i32> @llvm.smin.v2i32(<2 x i32> %sat.low, <2 x i32> <i32 127, i32 127>)
28 %trunc = trunc nsw <2 x i32> %sat.hi to <2 x i8>
29 %ret = bitcast <2 x i8> %trunc to i16
30 store i16 %ret, ptr addrspace(1) %out
34 define amdgpu_kernel void @v_ashr_pk_u8_i32(ptr addrspace(1) %out, i32 %src0, i32 %src1, i32 %src2) #0 {
35 ; GFX950-LABEL: v_ashr_pk_u8_i32:
37 ; GFX950-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x2c
38 ; GFX950-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x24
39 ; GFX950-NEXT: v_mov_b32_e32 v1, 0xff
40 ; GFX950-NEXT: v_mov_b32_e32 v0, 0
41 ; GFX950-NEXT: s_waitcnt lgkmcnt(0)
42 ; GFX950-NEXT: s_ashr_i32 s1, s1, s2
43 ; GFX950-NEXT: s_ashr_i32 s0, s0, s2
44 ; GFX950-NEXT: v_med3_i32 v2, s0, 0, v1
45 ; GFX950-NEXT: v_med3_i32 v1, s1, 0, v1
46 ; GFX950-NEXT: v_lshlrev_b32_e32 v1, 8, v1
47 ; GFX950-NEXT: v_or_b32_e32 v1, v2, v1
48 ; GFX950-NEXT: global_store_short v0, v1, s[6:7]
49 ; GFX950-NEXT: s_endpgm
50 %insert.0 = insertelement <2 x i32> poison, i32 %src0, i64 0
51 %build_vector = insertelement <2 x i32> %insert.0, i32 %src1, i64 1
52 %src2.clamp = and i32 %src2, 31
53 %insert.1 = insertelement <2 x i32> poison, i32 %src2.clamp, i64 0
54 %src2.broadcast = shufflevector <2 x i32> %insert.1, <2 x i32> poison, <2 x i32> zeroinitializer
55 %ashr = ashr <2 x i32> %build_vector, %src2.broadcast
56 %sat.low = tail call <2 x i32> @llvm.smax.v2i32(<2 x i32> %ashr, <2 x i32> <i32 0, i32 0>)
57 %sat.hi = tail call <2 x i32> @llvm.smin.v2i32(<2 x i32> %sat.low, <2 x i32> <i32 255, i32 255>)
58 %trunc = trunc nsw <2 x i32> %sat.hi to <2 x i8>
59 %ret = bitcast <2 x i8> %trunc to i16
60 store i16 %ret, ptr addrspace(1) %out