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_fmax_f32:
6 define amdgpu_kernel void @test_fmax_f32(float addrspace(1)* %out, float %a, float %b) #0 {
7 %val = call float @llvm.maxnum.f32(float %a, float %b)
8 store float %val, float addrspace(1)* %out, align 4
12 ; GCN-LABEL: {{^}}test_fmax_v2f32:
15 define amdgpu_kernel void @test_fmax_v2f32(<2 x float> addrspace(1)* %out, <2 x float> %a, <2 x float> %b) #0 {
16 %val = call <2 x float> @llvm.maxnum.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_fmax_v3f32:
26 define amdgpu_kernel void @test_fmax_v3f32(<3 x float> addrspace(1)* %out, <3 x float> %a, <3 x float> %b) nounwind {
27 %val = call <3 x float> @llvm.maxnum.v3f32(<3 x float> %a, <3 x float> %b) #0
28 store <3 x float> %val, <3 x float> addrspace(1)* %out, align 16
32 ; GCN-LABEL: {{^}}test_fmax_v4f32:
37 define amdgpu_kernel void @test_fmax_v4f32(<4 x float> addrspace(1)* %out, <4 x float> %a, <4 x float> %b) #0 {
38 %val = call <4 x float> @llvm.maxnum.v4f32(<4 x float> %a, <4 x float> %b)
39 store <4 x float> %val, <4 x float> addrspace(1)* %out, align 16
43 ; GCN-LABEL: {{^}}test_fmax_v8f32:
52 define amdgpu_kernel void @test_fmax_v8f32(<8 x float> addrspace(1)* %out, <8 x float> %a, <8 x float> %b) #0 {
53 %val = call <8 x float> @llvm.maxnum.v8f32(<8 x float> %a, <8 x float> %b)
54 store <8 x float> %val, <8 x float> addrspace(1)* %out, align 32
58 ; GCN-LABEL: {{^}}test_fmax_v16f32:
75 define amdgpu_kernel void @test_fmax_v16f32(<16 x float> addrspace(1)* %out, <16 x float> %a, <16 x float> %b) #0 {
76 %val = call <16 x float> @llvm.maxnum.v16f32(<16 x float> %a, <16 x float> %b)
77 store <16 x float> %val, <16 x float> addrspace(1)* %out, align 64
81 ; GCN-LABEL: {{^}}constant_fold_fmax_f32:
82 ; GCN-NOT: v_max_f32_e32
83 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 2.0
84 ; GCN: buffer_store_dword [[REG]]
85 define amdgpu_kernel void @constant_fold_fmax_f32(float addrspace(1)* %out) #0 {
86 %val = call float @llvm.maxnum.f32(float 1.0, float 2.0)
87 store float %val, float addrspace(1)* %out, align 4
91 ; GCN-LABEL: {{^}}constant_fold_fmax_f32_nan_nan:
92 ; GCN-NOT: v_max_f32_e32
93 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fc00000
94 ; GCN: buffer_store_dword [[REG]]
95 define amdgpu_kernel void @constant_fold_fmax_f32_nan_nan(float addrspace(1)* %out) #0 {
96 %val = call float @llvm.maxnum.f32(float 0x7FF8000000000000, float 0x7FF8000000000000)
97 store float %val, float addrspace(1)* %out, align 4
101 ; GCN-LABEL: {{^}}constant_fold_fmax_f32_val_nan:
102 ; GCN-NOT: v_max_f32_e32
103 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 1.0
104 ; GCN: buffer_store_dword [[REG]]
105 define amdgpu_kernel void @constant_fold_fmax_f32_val_nan(float addrspace(1)* %out) #0 {
106 %val = call float @llvm.maxnum.f32(float 1.0, float 0x7FF8000000000000)
107 store float %val, float addrspace(1)* %out, align 4
111 ; GCN-LABEL: {{^}}constant_fold_fmax_f32_nan_val:
112 ; GCN-NOT: v_max_f32_e32
113 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 1.0
114 ; GCN: buffer_store_dword [[REG]]
115 define amdgpu_kernel void @constant_fold_fmax_f32_nan_val(float addrspace(1)* %out) #0 {
116 %val = call float @llvm.maxnum.f32(float 0x7FF8000000000000, float 1.0)
117 store float %val, float addrspace(1)* %out, align 4
121 ; GCN-LABEL: {{^}}constant_fold_fmax_f32_p0_p0:
122 ; GCN-NOT: v_max_f32_e32
123 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0
124 ; GCN: buffer_store_dword [[REG]]
125 define amdgpu_kernel void @constant_fold_fmax_f32_p0_p0(float addrspace(1)* %out) #0 {
126 %val = call float @llvm.maxnum.f32(float 0.0, float 0.0)
127 store float %val, float addrspace(1)* %out, align 4
131 ; GCN-LABEL: {{^}}constant_fold_fmax_f32_p0_n0:
132 ; GCN-NOT: v_max_f32_e32
133 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0
134 ; GCN: buffer_store_dword [[REG]]
135 define amdgpu_kernel void @constant_fold_fmax_f32_p0_n0(float addrspace(1)* %out) #0 {
136 %val = call float @llvm.maxnum.f32(float 0.0, float -0.0)
137 store float %val, float addrspace(1)* %out, align 4
141 ; GCN-LABEL: {{^}}constant_fold_fmax_f32_n0_p0:
142 ; GCN-NOT: v_max_f32_e32
143 ; GCN: v_bfrev_b32_e32 [[REG:v[0-9]+]], 1{{$}}
144 ; GCN: buffer_store_dword [[REG]]
145 define amdgpu_kernel void @constant_fold_fmax_f32_n0_p0(float addrspace(1)* %out) #0 {
146 %val = call float @llvm.maxnum.f32(float -0.0, float 0.0)
147 store float %val, float addrspace(1)* %out, align 4
151 ; GCN-LABEL: {{^}}constant_fold_fmax_f32_n0_n0:
152 ; GCN-NOT: v_max_f32_e32
153 ; GCN: v_bfrev_b32_e32 [[REG:v[0-9]+]], 1{{$}}
154 ; GCN: buffer_store_dword [[REG]]
155 define amdgpu_kernel void @constant_fold_fmax_f32_n0_n0(float addrspace(1)* %out) #0 {
156 %val = call float @llvm.maxnum.f32(float -0.0, float -0.0)
157 store float %val, float addrspace(1)* %out, align 4
161 ; GCN-LABEL: {{^}}fmax_var_immediate_f32:
162 ; GCN: v_max_f32_e64 {{v[0-9]+}}, {{s[0-9]+}}, 2.0
163 define amdgpu_kernel void @fmax_var_immediate_f32(float addrspace(1)* %out, float %a) #0 {
164 %val = call float @llvm.maxnum.f32(float %a, float 2.0)
165 store float %val, float addrspace(1)* %out, align 4
169 ; GCN-LABEL: {{^}}fmax_immediate_var_f32:
170 ; GCN: v_max_f32_e64 {{v[0-9]+}}, {{s[0-9]+}}, 2.0
171 define amdgpu_kernel void @fmax_immediate_var_f32(float addrspace(1)* %out, float %a) #0 {
172 %val = call float @llvm.maxnum.f32(float 2.0, float %a)
173 store float %val, float addrspace(1)* %out, align 4
177 ; GCN-LABEL: {{^}}fmax_var_literal_f32:
178 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x42c60000
179 ; GCN: v_max_f32_e32 {{v[0-9]+}}, {{s[0-9]+}}, [[REG]]
180 define amdgpu_kernel void @fmax_var_literal_f32(float addrspace(1)* %out, float %a) #0 {
181 %val = call float @llvm.maxnum.f32(float %a, float 99.0)
182 store float %val, float addrspace(1)* %out, align 4
186 ; GCN-LABEL: {{^}}fmax_literal_var_f32:
187 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x42c60000
188 ; GCN: v_max_f32_e32 {{v[0-9]+}}, {{s[0-9]+}}, [[REG]]
189 define amdgpu_kernel void @fmax_literal_var_f32(float addrspace(1)* %out, float %a) #0 {
190 %val = call float @llvm.maxnum.f32(float 99.0, float %a)
191 store float %val, float addrspace(1)* %out, align 4
195 ; GCN-LABEL: {{^}}test_func_fmax_v3f32:
200 define <3 x float> @test_func_fmax_v3f32(<3 x float> %a, <3 x float> %b) nounwind {
201 %val = call <3 x float> @llvm.maxnum.v3f32(<3 x float> %a, <3 x float> %b) #0
205 declare float @llvm.maxnum.f32(float, float) #1
206 declare <2 x float> @llvm.maxnum.v2f32(<2 x float>, <2 x float>) #1
207 declare <3 x float> @llvm.maxnum.v3f32(<3 x float>, <3 x float>) #1
208 declare <4 x float> @llvm.maxnum.v4f32(<4 x float>, <4 x float>) #1
209 declare <8 x float> @llvm.maxnum.v8f32(<8 x float>, <8 x float>) #1
210 declare <16 x float> @llvm.maxnum.v16f32(<16 x float>, <16 x float>) #1
211 declare double @llvm.maxnum.f64(double, double)
213 attributes #0 = { nounwind }
214 attributes #1 = { nounwind readnone }