1 ; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
3 declare i32 @llvm.r600.read.tidig.x() #1
4 declare float @llvm.fabs.f32(float) #1
6 ; FUNC-LABEL: @commute_add_imm_fabs_f32
7 ; SI: buffer_load_dword [[X:v[0-9]+]], {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
8 ; SI: v_add_f32_e64 [[REG:v[0-9]+]], 2.0, |[[X]]|
9 ; SI-NEXT: buffer_store_dword [[REG]]
10 define void @commute_add_imm_fabs_f32(float addrspace(1)* %out, float addrspace(1)* %in) #0 {
11 %tid = call i32 @llvm.r600.read.tidig.x() #1
12 %gep.0 = getelementptr float addrspace(1)* %in, i32 %tid
13 %x = load float addrspace(1)* %gep.0
14 %x.fabs = call float @llvm.fabs.f32(float %x) #1
15 %z = fadd float 2.0, %x.fabs
16 store float %z, float addrspace(1)* %out
20 ; FUNC-LABEL: @commute_mul_imm_fneg_fabs_f32
21 ; SI: buffer_load_dword [[X:v[0-9]+]], {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
22 ; SI: v_mul_f32_e64 [[REG:v[0-9]+]], -4.0, |[[X]]|
23 ; SI-NEXT: buffer_store_dword [[REG]]
24 define void @commute_mul_imm_fneg_fabs_f32(float addrspace(1)* %out, float addrspace(1)* %in) #0 {
25 %tid = call i32 @llvm.r600.read.tidig.x() #1
26 %gep.0 = getelementptr float addrspace(1)* %in, i32 %tid
27 %x = load float addrspace(1)* %gep.0
28 %x.fabs = call float @llvm.fabs.f32(float %x) #1
29 %x.fneg.fabs = fsub float -0.000000e+00, %x.fabs
30 %z = fmul float 4.0, %x.fneg.fabs
31 store float %z, float addrspace(1)* %out
35 ; FUNC-LABEL: @commute_mul_imm_fneg_f32
36 ; SI: buffer_load_dword [[X:v[0-9]+]], {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
37 ; SI: v_mul_f32_e32 [[REG:v[0-9]+]], -4.0, [[X]]
38 ; SI-NEXT: buffer_store_dword [[REG]]
39 define void @commute_mul_imm_fneg_f32(float addrspace(1)* %out, float addrspace(1)* %in) #0 {
40 %tid = call i32 @llvm.r600.read.tidig.x() #1
41 %gep.0 = getelementptr float addrspace(1)* %in, i32 %tid
42 %x = load float addrspace(1)* %gep.0
43 %x.fneg = fsub float -0.000000e+00, %x
44 %z = fmul float 4.0, %x.fneg
45 store float %z, float addrspace(1)* %out
49 attributes #0 = { nounwind }
50 attributes #1 = { nounwind readnone }