1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -global-isel=0 -march=amdgcn -mcpu=tahiti -amdgpu-codegenprepare-mul24=0 -amdgpu-codegenprepare-disable-idiv-expansion < %s | FileCheck -check-prefixes=SI,SI-SDAG %s
3 ; RUN: llc -global-isel=1 -march=amdgcn -mcpu=tahiti -amdgpu-codegenprepare-mul24=0 -amdgpu-codegenprepare-disable-idiv-expansion < %s | FileCheck -check-prefixes=SI,SI-GISEL %s
5 declare i32 @llvm.smin.i32(i32, i32)
6 declare i32 @llvm.smax.i32(i32, i32)
7 declare i32 @llvm.umin.i32(i32, i32)
8 declare i32 @llvm.umax.i32(i32, i32)
10 ; Test computeKnownBits for umed3 node. We know the base address has a
11 ; 0 sign bit only after umed3 is formed. The DS instruction offset can
12 ; only be folded on SI with a positive base address.
13 define i32 @v_known_bits_umed3(i8 %a) {
14 ; SI-SDAG-LABEL: v_known_bits_umed3:
16 ; SI-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
17 ; SI-SDAG-NEXT: v_and_b32_e32 v0, 0xff, v0
18 ; SI-SDAG-NEXT: v_mov_b32_e32 v1, 0x80
19 ; SI-SDAG-NEXT: v_med3_u32 v0, v0, 32, v1
20 ; SI-SDAG-NEXT: s_mov_b32 m0, -1
21 ; SI-SDAG-NEXT: ds_read_u8 v0, v0 offset:128
22 ; SI-SDAG-NEXT: s_waitcnt lgkmcnt(0)
23 ; SI-SDAG-NEXT: s_setpc_b64 s[30:31]
25 ; SI-GISEL-LABEL: v_known_bits_umed3:
27 ; SI-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
28 ; SI-GISEL-NEXT: v_and_b32_e32 v0, 0xff, v0
29 ; SI-GISEL-NEXT: v_mov_b32_e32 v1, 0x80
30 ; SI-GISEL-NEXT: v_med3_u32 v0, v0, 32, v1
31 ; SI-GISEL-NEXT: ds_read_u8 v0, v0 offset:128
32 ; SI-GISEL-NEXT: s_waitcnt lgkmcnt(0)
33 ; SI-GISEL-NEXT: s_setpc_b64 s[30:31]
34 %ext.a = zext i8 %a to i32
35 %max.a = call i32 @llvm.umax.i32(i32 %ext.a, i32 32)
36 %umed3 = call i32 @llvm.umin.i32(i32 %max.a, i32 128)
37 %cast.umed3 = inttoptr i32 %umed3 to ptr addrspace(3)
38 %gep = getelementptr i8, ptr addrspace(3) %cast.umed3, i32 128
39 %load = load i8, ptr addrspace(3) %gep
40 %result = zext i8 %load to i32
44 ; The IR expansion of division is disabled. The division is legalized
45 ; late, after the formation of smed3. We need to be able to
46 ; computeNumSignBits on the smed3 in order to use the 24-bit-as-float
48 define i32 @v_known_signbits_smed3(i16 %a, i16 %b) {
49 ; SI-SDAG-LABEL: v_known_signbits_smed3:
51 ; SI-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
52 ; SI-SDAG-NEXT: v_bfe_i32 v1, v1, 0, 16
53 ; SI-SDAG-NEXT: s_movk_i32 s4, 0xffc0
54 ; SI-SDAG-NEXT: v_mov_b32_e32 v2, 0x80
55 ; SI-SDAG-NEXT: v_med3_i32 v1, v1, s4, v2
56 ; SI-SDAG-NEXT: v_cvt_f32_i32_e32 v2, v1
57 ; SI-SDAG-NEXT: v_bfe_i32 v0, v0, 0, 16
58 ; SI-SDAG-NEXT: s_movk_i32 s4, 0xffe0
59 ; SI-SDAG-NEXT: v_med3_i32 v0, v0, s4, 64
60 ; SI-SDAG-NEXT: v_cvt_f32_i32_e32 v3, v0
61 ; SI-SDAG-NEXT: v_rcp_iflag_f32_e32 v4, v2
62 ; SI-SDAG-NEXT: v_xor_b32_e32 v0, v0, v1
63 ; SI-SDAG-NEXT: v_ashrrev_i32_e32 v0, 30, v0
64 ; SI-SDAG-NEXT: v_or_b32_e32 v0, 1, v0
65 ; SI-SDAG-NEXT: v_mul_f32_e32 v1, v3, v4
66 ; SI-SDAG-NEXT: v_trunc_f32_e32 v1, v1
67 ; SI-SDAG-NEXT: v_mad_f32 v3, -v1, v2, v3
68 ; SI-SDAG-NEXT: v_cvt_i32_f32_e32 v1, v1
69 ; SI-SDAG-NEXT: v_cmp_ge_f32_e64 vcc, |v3|, |v2|
70 ; SI-SDAG-NEXT: v_cndmask_b32_e32 v0, 0, v0, vcc
71 ; SI-SDAG-NEXT: v_add_i32_e32 v0, vcc, v1, v0
72 ; SI-SDAG-NEXT: v_bfe_i32 v0, v0, 0, 16
73 ; SI-SDAG-NEXT: s_setpc_b64 s[30:31]
75 ; SI-GISEL-LABEL: v_known_signbits_smed3:
77 ; SI-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
78 ; SI-GISEL-NEXT: v_bfe_i32 v1, v1, 0, 16
79 ; SI-GISEL-NEXT: v_mov_b32_e32 v2, 0xffffffc0
80 ; SI-GISEL-NEXT: v_mov_b32_e32 v3, 0x80
81 ; SI-GISEL-NEXT: v_med3_i32 v1, v1, v2, v3
82 ; SI-GISEL-NEXT: v_ashrrev_i32_e32 v2, 31, v1
83 ; SI-GISEL-NEXT: v_add_i32_e32 v1, vcc, v1, v2
84 ; SI-GISEL-NEXT: v_xor_b32_e32 v1, v1, v2
85 ; SI-GISEL-NEXT: v_cvt_f32_u32_e32 v3, v1
86 ; SI-GISEL-NEXT: v_sub_i32_e32 v5, vcc, 0, v1
87 ; SI-GISEL-NEXT: v_mov_b32_e32 v4, 0xffffffe0
88 ; SI-GISEL-NEXT: v_rcp_iflag_f32_e32 v3, v3
89 ; SI-GISEL-NEXT: v_bfe_i32 v0, v0, 0, 16
90 ; SI-GISEL-NEXT: v_med3_i32 v0, v0, v4, 64
91 ; SI-GISEL-NEXT: v_ashrrev_i32_e32 v4, 31, v0
92 ; SI-GISEL-NEXT: v_mul_f32_e32 v3, 0x4f7ffffe, v3
93 ; SI-GISEL-NEXT: v_cvt_u32_f32_e32 v3, v3
94 ; SI-GISEL-NEXT: v_add_i32_e32 v0, vcc, v0, v4
95 ; SI-GISEL-NEXT: v_xor_b32_e32 v0, v0, v4
96 ; SI-GISEL-NEXT: v_mul_lo_u32 v5, v5, v3
97 ; SI-GISEL-NEXT: v_mul_hi_u32 v5, v3, v5
98 ; SI-GISEL-NEXT: v_add_i32_e32 v3, vcc, v3, v5
99 ; SI-GISEL-NEXT: v_mul_hi_u32 v3, v0, v3
100 ; SI-GISEL-NEXT: v_mul_lo_u32 v5, v3, v1
101 ; SI-GISEL-NEXT: v_add_i32_e32 v6, vcc, 1, v3
102 ; SI-GISEL-NEXT: v_sub_i32_e32 v0, vcc, v0, v5
103 ; SI-GISEL-NEXT: v_cmp_ge_u32_e32 vcc, v0, v1
104 ; SI-GISEL-NEXT: v_cndmask_b32_e32 v3, v3, v6, vcc
105 ; SI-GISEL-NEXT: v_sub_i32_e64 v5, s[4:5], v0, v1
106 ; SI-GISEL-NEXT: v_cndmask_b32_e32 v0, v0, v5, vcc
107 ; SI-GISEL-NEXT: v_add_i32_e32 v5, vcc, 1, v3
108 ; SI-GISEL-NEXT: v_cmp_ge_u32_e32 vcc, v0, v1
109 ; SI-GISEL-NEXT: v_cndmask_b32_e32 v0, v3, v5, vcc
110 ; SI-GISEL-NEXT: v_xor_b32_e32 v1, v4, v2
111 ; SI-GISEL-NEXT: v_xor_b32_e32 v0, v0, v1
112 ; SI-GISEL-NEXT: v_sub_i32_e32 v0, vcc, v0, v1
113 ; SI-GISEL-NEXT: s_setpc_b64 s[30:31]
114 %ext.a = sext i16 %a to i32
115 %max.a = call i32 @llvm.smax.i32(i32 %ext.a, i32 -32)
116 %smed3.a = call i32 @llvm.smin.i32(i32 %max.a, i32 64)
117 %ext.b = sext i16 %b to i32
118 %max.b = call i32 @llvm.smax.i32(i32 %ext.b, i32 -64)
119 %smed3.b = call i32 @llvm.smin.i32(i32 %max.b, i32 128)
120 %mul = sdiv i32 %smed3.a, %smed3.b
123 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: