1; RUN: llc -march=amdgcn -mcpu=SI -enable-misched < %s | FileCheck -check-prefix=SI -check-prefix=GCN -check-prefix=FUNC %s 2; RUN: llc -march=amdgcn -mcpu=bonaire -enable-misched < %s | FileCheck -check-prefix=CI -check-prefix=GCN -check-prefix=FUNC %s 3; RUN: llc -march=amdgcn -mcpu=tonga -enable-misched < %s | FileCheck -check-prefix=CI -check-prefix=GCN -check-prefix=FUNC %s 4 5; FUNC-LABEL: {{^}}frem_f32: 6; GCN-DAG: buffer_load_dword [[X:v[0-9]+]], {{.*$}} 7; GCN-DAG: buffer_load_dword [[Y:v[0-9]+]], {{.*}} offset:16 8; GCN: v_div_scale_f32 9 10; GCN: v_rcp_f32_e32 11; GCN: v_fma_f32 12; GCN: v_mul_f32_e32 13; GCN: v_div_fmas_f32 14; GCN: v_div_fixup_f32 15; GCN: v_trunc_f32_e32 16; GCN: v_mad_f32 17; GCN: s_endpgm 18define void @frem_f32(float addrspace(1)* %out, float addrspace(1)* %in1, 19 float addrspace(1)* %in2) #0 { 20 %gep2 = getelementptr float, float addrspace(1)* %in2, i32 4 21 %r0 = load float, float addrspace(1)* %in1, align 4 22 %r1 = load float, float addrspace(1)* %gep2, align 4 23 %r2 = frem float %r0, %r1 24 store float %r2, float addrspace(1)* %out, align 4 25 ret void 26} 27 28; FUNC-LABEL: {{^}}unsafe_frem_f32: 29; GCN: buffer_load_dword [[Y:v[0-9]+]], {{.*}} offset:16 30; GCN: buffer_load_dword [[X:v[0-9]+]], {{.*}} 31; GCN: v_rcp_f32_e32 [[INVY:v[0-9]+]], [[Y]] 32; GCN: v_mul_f32_e32 [[DIV:v[0-9]+]], [[INVY]], [[X]] 33; GCN: v_trunc_f32_e32 [[TRUNC:v[0-9]+]], [[DIV]] 34; GCN: v_mad_f32 [[RESULT:v[0-9]+]], -[[TRUNC]], [[Y]], [[X]] 35; GCN: buffer_store_dword [[RESULT]] 36; GCN: s_endpgm 37define void @unsafe_frem_f32(float addrspace(1)* %out, float addrspace(1)* %in1, 38 float addrspace(1)* %in2) #1 { 39 %gep2 = getelementptr float, float addrspace(1)* %in2, i32 4 40 %r0 = load float, float addrspace(1)* %in1, align 4 41 %r1 = load float, float addrspace(1)* %gep2, align 4 42 %r2 = frem float %r0, %r1 43 store float %r2, float addrspace(1)* %out, align 4 44 ret void 45} 46 47; FUNC-LABEL: {{^}}frem_f64: 48; GCN: buffer_load_dwordx2 [[Y:v\[[0-9]+:[0-9]+\]]], {{.*}}, 0 49; GCN: buffer_load_dwordx2 [[X:v\[[0-9]+:[0-9]+\]]], {{.*}}, 0 50; GCN-DAG: v_div_fmas_f64 51; GCN-DAG: v_div_scale_f64 52; GCN-DAG: v_mul_f64 53; CI: v_trunc_f64_e32 54; CI: v_mul_f64 55; GCN: v_add_f64 56; GCN: buffer_store_dwordx2 57; GCN: s_endpgm 58define void @frem_f64(double addrspace(1)* %out, double addrspace(1)* %in1, 59 double addrspace(1)* %in2) #0 { 60 %r0 = load double, double addrspace(1)* %in1, align 8 61 %r1 = load double, double addrspace(1)* %in2, align 8 62 %r2 = frem double %r0, %r1 63 store double %r2, double addrspace(1)* %out, align 8 64 ret void 65} 66 67; FUNC-LABEL: {{^}}unsafe_frem_f64: 68; GCN: v_rcp_f64_e32 69; GCN: v_mul_f64 70; SI: v_bfe_u32 71; CI: v_trunc_f64_e32 72; GCN: v_fma_f64 73; GCN: s_endpgm 74define void @unsafe_frem_f64(double addrspace(1)* %out, double addrspace(1)* %in1, 75 double addrspace(1)* %in2) #1 { 76 %r0 = load double, double addrspace(1)* %in1, align 8 77 %r1 = load double, double addrspace(1)* %in2, align 8 78 %r2 = frem double %r0, %r1 79 store double %r2, double addrspace(1)* %out, align 8 80 ret void 81} 82 83define void @frem_v2f32(<2 x float> addrspace(1)* %out, <2 x float> addrspace(1)* %in1, 84 <2 x float> addrspace(1)* %in2) #0 { 85 %gep2 = getelementptr <2 x float>, <2 x float> addrspace(1)* %in2, i32 4 86 %r0 = load <2 x float>, <2 x float> addrspace(1)* %in1, align 8 87 %r1 = load <2 x float>, <2 x float> addrspace(1)* %gep2, align 8 88 %r2 = frem <2 x float> %r0, %r1 89 store <2 x float> %r2, <2 x float> addrspace(1)* %out, align 8 90 ret void 91} 92 93define void @frem_v4f32(<4 x float> addrspace(1)* %out, <4 x float> addrspace(1)* %in1, 94 <4 x float> addrspace(1)* %in2) #0 { 95 %gep2 = getelementptr <4 x float>, <4 x float> addrspace(1)* %in2, i32 4 96 %r0 = load <4 x float>, <4 x float> addrspace(1)* %in1, align 16 97 %r1 = load <4 x float>, <4 x float> addrspace(1)* %gep2, align 16 98 %r2 = frem <4 x float> %r0, %r1 99 store <4 x float> %r2, <4 x float> addrspace(1)* %out, align 16 100 ret void 101} 102 103define void @frem_v2f64(<2 x double> addrspace(1)* %out, <2 x double> addrspace(1)* %in1, 104 <2 x double> addrspace(1)* %in2) #0 { 105 %gep2 = getelementptr <2 x double>, <2 x double> addrspace(1)* %in2, i32 4 106 %r0 = load <2 x double>, <2 x double> addrspace(1)* %in1, align 16 107 %r1 = load <2 x double>, <2 x double> addrspace(1)* %gep2, align 16 108 %r2 = frem <2 x double> %r0, %r1 109 store <2 x double> %r2, <2 x double> addrspace(1)* %out, align 16 110 ret void 111} 112 113attributes #0 = { nounwind "unsafe-fp-math"="false" } 114attributes #1 = { nounwind "unsafe-fp-math"="true" } 115