1; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s 2 3declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone 4 5declare double @fabs(double) readnone 6declare double @llvm.fabs.f64(double) readnone 7declare <2 x double> @llvm.fabs.v2f64(<2 x double>) readnone 8declare <4 x double> @llvm.fabs.v4f64(<4 x double>) readnone 9 10; FUNC-LABEL: {{^}}v_fabs_f64: 11; SI: v_and_b32 12; SI: s_endpgm 13define void @v_fabs_f64(double addrspace(1)* %out, double addrspace(1)* %in) { 14 %tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone 15 %tidext = sext i32 %tid to i64 16 %gep = getelementptr double, double addrspace(1)* %in, i64 %tidext 17 %val = load double, double addrspace(1)* %gep, align 8 18 %fabs = call double @llvm.fabs.f64(double %val) 19 store double %fabs, double addrspace(1)* %out 20 ret void 21} 22 23; FUNC-LABEL: {{^}}fabs_f64: 24; SI: v_and_b32 25; SI-NOT: v_and_b32 26; SI: s_endpgm 27define void @fabs_f64(double addrspace(1)* %out, double %in) { 28 %fabs = call double @llvm.fabs.f64(double %in) 29 store double %fabs, double addrspace(1)* %out 30 ret void 31} 32 33; FUNC-LABEL: {{^}}fabs_v2f64: 34; SI: v_and_b32 35; SI: v_and_b32 36; SI: s_endpgm 37define void @fabs_v2f64(<2 x double> addrspace(1)* %out, <2 x double> %in) { 38 %fabs = call <2 x double> @llvm.fabs.v2f64(<2 x double> %in) 39 store <2 x double> %fabs, <2 x double> addrspace(1)* %out 40 ret void 41} 42 43; FUNC-LABEL: {{^}}fabs_v4f64: 44; SI: v_and_b32 45; SI: v_and_b32 46; SI: v_and_b32 47; SI: v_and_b32 48; SI: s_endpgm 49define void @fabs_v4f64(<4 x double> addrspace(1)* %out, <4 x double> %in) { 50 %fabs = call <4 x double> @llvm.fabs.v4f64(<4 x double> %in) 51 store <4 x double> %fabs, <4 x double> addrspace(1)* %out 52 ret void 53} 54 55; SI-LABEL: {{^}}fabs_fold_f64: 56; SI: s_load_dwordx2 [[ABS_VALUE:s\[[0-9]+:[0-9]+\]]], {{s\[[0-9]+:[0-9]+\]}}, 0xb 57; SI-NOT: and 58; SI: v_mul_f64 {{v\[[0-9]+:[0-9]+\]}}, |[[ABS_VALUE]]|, {{v\[[0-9]+:[0-9]+\]}} 59; SI: s_endpgm 60define void @fabs_fold_f64(double addrspace(1)* %out, double %in0, double %in1) { 61 %fabs = call double @llvm.fabs.f64(double %in0) 62 %fmul = fmul double %fabs, %in1 63 store double %fmul, double addrspace(1)* %out 64 ret void 65} 66 67; SI-LABEL: {{^}}fabs_fn_fold_f64: 68; SI: s_load_dwordx2 [[ABS_VALUE:s\[[0-9]+:[0-9]+\]]], {{s\[[0-9]+:[0-9]+\]}}, 0xb 69; SI-NOT: and 70; SI: v_mul_f64 {{v\[[0-9]+:[0-9]+\]}}, |[[ABS_VALUE]]|, {{v\[[0-9]+:[0-9]+\]}} 71; SI: s_endpgm 72define void @fabs_fn_fold_f64(double addrspace(1)* %out, double %in0, double %in1) { 73 %fabs = call double @fabs(double %in0) 74 %fmul = fmul double %fabs, %in1 75 store double %fmul, double addrspace(1)* %out 76 ret void 77} 78 79; FUNC-LABEL: {{^}}fabs_free_f64: 80; SI: v_and_b32 81; SI: s_endpgm 82define void @fabs_free_f64(double addrspace(1)* %out, i64 %in) { 83 %bc= bitcast i64 %in to double 84 %fabs = call double @llvm.fabs.f64(double %bc) 85 store double %fabs, double addrspace(1)* %out 86 ret void 87} 88 89; FUNC-LABEL: {{^}}fabs_fn_free_f64: 90; SI: v_and_b32 91; SI: s_endpgm 92define void @fabs_fn_free_f64(double addrspace(1)* %out, i64 %in) { 93 %bc= bitcast i64 %in to double 94 %fabs = call double @fabs(double %bc) 95 store double %fabs, double addrspace(1)* %out 96 ret void 97} 98