1 ; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=GCN %s
2 ; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=GCN %s
4 ; GCN-LABEL: {{^}}test_fmin_f32:
6 define amdgpu_kernel void @test_fmin_f32(float addrspace(1)* %out, float %a, float %b) #0 {
7 %val = call float @llvm.minnum.f32(float %a, float %b)
8 store float %val, float addrspace(1)* %out, align 4
12 ; GCN-LABEL: {{^}}test_fmin_v2f32:
15 define amdgpu_kernel void @test_fmin_v2f32(<2 x float> addrspace(1)* %out, <2 x float> %a, <2 x float> %b) #0 {
16 %val = call <2 x float> @llvm.minnum.v2f32(<2 x float> %a, <2 x float> %b)
17 store <2 x float> %val, <2 x float> addrspace(1)* %out, align 8
21 ; GCN-LABEL: {{^}}test_fmin_v4f32:
26 define amdgpu_kernel void @test_fmin_v4f32(<4 x float> addrspace(1)* %out, <4 x float> %a, <4 x float> %b) #0 {
27 %val = call <4 x float> @llvm.minnum.v4f32(<4 x float> %a, <4 x float> %b)
28 store <4 x float> %val, <4 x float> addrspace(1)* %out, align 16
32 ; GCN-LABEL: {{^}}test_fmin_v8f32:
41 define amdgpu_kernel void @test_fmin_v8f32(<8 x float> addrspace(1)* %out, <8 x float> %a, <8 x float> %b) #0 {
42 %val = call <8 x float> @llvm.minnum.v8f32(<8 x float> %a, <8 x float> %b)
43 store <8 x float> %val, <8 x float> addrspace(1)* %out, align 32
47 ; GCN-LABEL: {{^}}test_fmin_v16f32:
64 define amdgpu_kernel void @test_fmin_v16f32(<16 x float> addrspace(1)* %out, <16 x float> %a, <16 x float> %b) #0 {
65 %val = call <16 x float> @llvm.minnum.v16f32(<16 x float> %a, <16 x float> %b)
66 store <16 x float> %val, <16 x float> addrspace(1)* %out, align 64
70 ; GCN-LABEL: {{^}}constant_fold_fmin_f32:
71 ; GCN-NOT: v_min_f32_e32
72 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 1.0
73 ; GCN: buffer_store_dword [[REG]]
74 define amdgpu_kernel void @constant_fold_fmin_f32(float addrspace(1)* %out) #0 {
75 %val = call float @llvm.minnum.f32(float 1.0, float 2.0)
76 store float %val, float addrspace(1)* %out, align 4
80 ; GCN-LABEL: {{^}}constant_fold_fmin_f32_nan_nan:
81 ; GCN-NOT: v_min_f32_e32
82 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fc00000
83 ; GCN: buffer_store_dword [[REG]]
84 define amdgpu_kernel void @constant_fold_fmin_f32_nan_nan(float addrspace(1)* %out) #0 {
85 %val = call float @llvm.minnum.f32(float 0x7FF8000000000000, float 0x7FF8000000000000)
86 store float %val, float addrspace(1)* %out, align 4
90 ; GCN-LABEL: {{^}}constant_fold_fmin_f32_val_nan:
91 ; GCN-NOT: v_min_f32_e32
92 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 1.0
93 ; GCN: buffer_store_dword [[REG]]
94 define amdgpu_kernel void @constant_fold_fmin_f32_val_nan(float addrspace(1)* %out) #0 {
95 %val = call float @llvm.minnum.f32(float 1.0, float 0x7FF8000000000000)
96 store float %val, float addrspace(1)* %out, align 4
100 ; GCN-LABEL: {{^}}constant_fold_fmin_f32_nan_val:
101 ; GCN-NOT: v_min_f32_e32
102 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 1.0
103 ; GCN: buffer_store_dword [[REG]]
104 define amdgpu_kernel void @constant_fold_fmin_f32_nan_val(float addrspace(1)* %out) #0 {
105 %val = call float @llvm.minnum.f32(float 0x7FF8000000000000, float 1.0)
106 store float %val, float addrspace(1)* %out, align 4
110 ; GCN-LABEL: {{^}}constant_fold_fmin_f32_p0_p0:
111 ; GCN-NOT: v_min_f32_e32
112 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0
113 ; GCN: buffer_store_dword [[REG]]
114 define amdgpu_kernel void @constant_fold_fmin_f32_p0_p0(float addrspace(1)* %out) #0 {
115 %val = call float @llvm.minnum.f32(float 0.0, float 0.0)
116 store float %val, float addrspace(1)* %out, align 4
120 ; GCN-LABEL: {{^}}constant_fold_fmin_f32_p0_n0:
121 ; GCN-NOT: v_min_f32_e32
122 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0
123 ; GCN: buffer_store_dword [[REG]]
124 define amdgpu_kernel void @constant_fold_fmin_f32_p0_n0(float addrspace(1)* %out) #0 {
125 %val = call float @llvm.minnum.f32(float 0.0, float -0.0)
126 store float %val, float addrspace(1)* %out, align 4
130 ; GCN-LABEL: {{^}}constant_fold_fmin_f32_n0_p0:
131 ; GCN-NOT: v_min_f32_e32
132 ; GCN: v_bfrev_b32_e32 [[REG:v[0-9]+]], 1{{$}}
133 ; GCN: buffer_store_dword [[REG]]
134 define amdgpu_kernel void @constant_fold_fmin_f32_n0_p0(float addrspace(1)* %out) #0 {
135 %val = call float @llvm.minnum.f32(float -0.0, float 0.0)
136 store float %val, float addrspace(1)* %out, align 4
140 ; GCN-LABEL: {{^}}constant_fold_fmin_f32_n0_n0:
141 ; GCN-NOT: v_min_f32_e32
142 ; GCN: v_bfrev_b32_e32 [[REG:v[0-9]+]], 1{{$}}
143 ; GCN: buffer_store_dword [[REG]]
144 define amdgpu_kernel void @constant_fold_fmin_f32_n0_n0(float addrspace(1)* %out) #0 {
145 %val = call float @llvm.minnum.f32(float -0.0, float -0.0)
146 store float %val, float addrspace(1)* %out, align 4
150 ; GCN-LABEL: {{^}}fmin_var_immediate_f32:
151 ; GCN: v_min_f32_e64 {{v[0-9]+}}, {{s[0-9]+}}, 2.0
152 define amdgpu_kernel void @fmin_var_immediate_f32(float addrspace(1)* %out, float %a) #0 {
153 %val = call float @llvm.minnum.f32(float %a, float 2.0)
154 store float %val, float addrspace(1)* %out, align 4
158 ; GCN-LABEL: {{^}}fmin_immediate_var_f32:
159 ; GCN: v_min_f32_e64 {{v[0-9]+}}, {{s[0-9]+}}, 2.0
160 define amdgpu_kernel void @fmin_immediate_var_f32(float addrspace(1)* %out, float %a) #0 {
161 %val = call float @llvm.minnum.f32(float 2.0, float %a)
162 store float %val, float addrspace(1)* %out, align 4
166 ; GCN-LABEL: {{^}}fmin_var_literal_f32:
167 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x42c60000
168 ; GCN: v_min_f32_e32 {{v[0-9]+}}, {{s[0-9]+}}, [[REG]]
169 define amdgpu_kernel void @fmin_var_literal_f32(float addrspace(1)* %out, float %a) #0 {
170 %val = call float @llvm.minnum.f32(float %a, float 99.0)
171 store float %val, float addrspace(1)* %out, align 4
175 ; GCN-LABEL: {{^}}fmin_literal_var_f32:
176 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x42c60000
177 ; GCN: v_min_f32_e32 {{v[0-9]+}}, {{s[0-9]+}}, [[REG]]
178 define amdgpu_kernel void @fmin_literal_var_f32(float addrspace(1)* %out, float %a) #0 {
179 %val = call float @llvm.minnum.f32(float 99.0, float %a)
180 store float %val, float addrspace(1)* %out, align 4
184 ; GCN-LABEL: {{^}}test_func_fmin_v3f32:
189 define <3 x float> @test_func_fmin_v3f32(<3 x float> %a, <3 x float> %b) nounwind {
190 %val = call <3 x float> @llvm.minnum.v3f32(<3 x float> %a, <3 x float> %b) #0
194 declare float @llvm.minnum.f32(float, float) #1
195 declare <2 x float> @llvm.minnum.v2f32(<2 x float>, <2 x float>) #1
196 declare <3 x float> @llvm.minnum.v3f32(<3 x float>, <3 x float>) #1
197 declare <4 x float> @llvm.minnum.v4f32(<4 x float>, <4 x float>) #1
198 declare <8 x float> @llvm.minnum.v8f32(<8 x float>, <8 x float>) #1
199 declare <16 x float> @llvm.minnum.v16f32(<16 x float>, <16 x float>) #1
201 attributes #0 = { nounwind }
202 attributes #1 = { nounwind readnone }