186 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 22; RUN: opt -S -mtriple=amdgcn-- -passes=amdgpu-simplifylib < %s | FileCheck %s3 4; sin, cos, and sincos are already defined in the module.5 6define float @_Z3sinf(float %x) {7; CHECK-LABEL: define float @_Z3sinf8; CHECK-SAME: (float [[X:%.*]]) {9; CHECK-NEXT: [[RESULT:%.*]] = call float asm "10; CHECK-NEXT: ret float [[RESULT]]11;12 %result = call float asm "; $0 = sin($1)","=v,v"(float %x)13 ret float %result14}15 16define float @_Z3cosf(float %x) {17; CHECK-LABEL: define float @_Z3cosf18; CHECK-SAME: (float [[X:%.*]]) {19; CHECK-NEXT: [[RESULT:%.*]] = call float asm "20; CHECK-NEXT: ret float [[RESULT]]21;22 %result = call float asm "; $0 = cos($1)","=v,v"(float %x)23 ret float %result24}25 26define <2 x float> @_Z3sinDv2_f(<2 x float> %x) {27; CHECK-LABEL: define <2 x float> @_Z3sinDv2_f28; CHECK-SAME: (<2 x float> [[X:%.*]]) {29; CHECK-NEXT: [[RESULT:%.*]] = call <2 x float> asm "30; CHECK-NEXT: ret <2 x float> [[RESULT]]31;32 %result = call <2 x float> asm "; $0 = sin($1)","=v,v"(<2 x float> %x)33 ret <2 x float> %result34}35 36define <2 x float> @_Z3cosDv2_f(<2 x float> %x) {37; CHECK-LABEL: define <2 x float> @_Z3cosDv2_f38; CHECK-SAME: (<2 x float> [[X:%.*]]) {39; CHECK-NEXT: [[RESULT:%.*]] = call <2 x float> asm "40; CHECK-NEXT: ret <2 x float> [[RESULT]]41;42 %result = call <2 x float> asm "; $0 = cos($1)","=v,v"(<2 x float> %x)43 ret <2 x float> %result44}45 46define float @_Z6sincosfPU3AS5f(float %x, ptr addrspace(5) %ptr) {47; CHECK-LABEL: define float @_Z6sincosfPU3AS5f48; CHECK-SAME: (float [[X:%.*]], ptr addrspace(5) [[PTR:%.*]]) {49; CHECK-NEXT: [[RESULT0:%.*]] = call float asm "50; CHECK-NEXT: [[RESULT1:%.*]] = call float asm "51; CHECK-NEXT: store float [[RESULT1]], ptr addrspace(5) [[PTR]], align 452; CHECK-NEXT: ret float [[RESULT0]]53;54 %result0 = call float asm "; $0 = sin($1)","=v,v"(float %x)55 %result1 = call float asm "; $0 = cos($1)","=v,v"(float %x)56 store float %result1, ptr addrspace(5) %ptr57 ret float %result058}59 60define <2 x float> @_Z6sincosDv2_fPU3AS5S_(<2 x float> %x, ptr addrspace(5) %ptr) {61; CHECK-LABEL: define <2 x float> @_Z6sincosDv2_fPU3AS5S_62; CHECK-SAME: (<2 x float> [[X:%.*]], ptr addrspace(5) [[PTR:%.*]]) {63; CHECK-NEXT: [[RESULT0:%.*]] = call <2 x float> asm "64; CHECK-NEXT: [[RESULT1:%.*]] = call <2 x float> asm "65; CHECK-NEXT: store <2 x float> [[RESULT1]], ptr addrspace(5) [[PTR]], align 866; CHECK-NEXT: ret <2 x float> [[RESULT0]]67;68 %result0 = call <2 x float> asm "; $0 = sin($1)","=v,v"(<2 x float> %x)69 %result1 = call <2 x float> asm "; $0 = cos($1)","=v,v"(<2 x float> %x)70 store <2 x float> %result1, ptr addrspace(5) %ptr71 ret <2 x float> %result072}73 74define float @_Z6sincosfPU3AS0f(float %x, ptr %ptr) {75; CHECK-LABEL: define float @_Z6sincosfPU3AS0f76; CHECK-SAME: (float [[X:%.*]], ptr [[PTR:%.*]]) {77; CHECK-NEXT: [[RESULT0:%.*]] = call float asm "78; CHECK-NEXT: [[RESULT1:%.*]] = call float asm "79; CHECK-NEXT: store float [[RESULT1]], ptr [[PTR]], align 480; CHECK-NEXT: ret float [[RESULT0]]81;82 %result0 = call float asm "; $0 = sin($1)","=v,v"(float %x)83 %result1 = call float asm "; $0 = cos($1)","=v,v"(float %x)84 store float %result1, ptr %ptr85 ret float %result086}87 88define <2 x float> @_Z6sincosDv2_fPU3AS0S_(<2 x float> %x, ptr %ptr) {89; CHECK-LABEL: define <2 x float> @_Z6sincosDv2_fPU3AS0S_90; CHECK-SAME: (<2 x float> [[X:%.*]], ptr [[PTR:%.*]]) {91; CHECK-NEXT: [[RESULT0:%.*]] = call <2 x float> asm "92; CHECK-NEXT: [[RESULT1:%.*]] = call <2 x float> asm "93; CHECK-NEXT: store <2 x float> [[RESULT1]], ptr [[PTR]], align 894; CHECK-NEXT: ret <2 x float> [[RESULT0]]95;96 %result0 = call <2 x float> asm "; $0 = sin($1)","=v,v"(<2 x float> %x)97 %result1 = call <2 x float> asm "; $0 = cos($1)","=v,v"(<2 x float> %x)98 store <2 x float> %result1, ptr %ptr99 ret <2 x float> %result0100}101 102define void @sincos_f32(float %x, ptr addrspace(1) nocapture writeonly %sin_out, ptr addrspace(1) nocapture writeonly %cos_out) {103; CHECK-LABEL: define void @sincos_f32104; CHECK-SAME: (float [[X:%.*]], ptr addrspace(1) writeonly captures(none) [[SIN_OUT:%.*]], ptr addrspace(1) writeonly captures(none) [[COS_OUT:%.*]]) {105; CHECK-NEXT: entry:106; CHECK-NEXT: [[__SINCOS_:%.*]] = alloca float, align 4, addrspace(5)107; CHECK-NEXT: [[TMP0:%.*]] = call contract float @_Z6sincosfPU3AS5f(float [[X]], ptr addrspace(5) [[__SINCOS_]])108; CHECK-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(5) [[__SINCOS_]], align 4109; CHECK-NEXT: store float [[TMP0]], ptr addrspace(1) [[SIN_OUT]], align 4110; CHECK-NEXT: [[CALL1:%.*]] = tail call contract float @_Z3cosf(float [[X]])111; CHECK-NEXT: store float [[TMP1]], ptr addrspace(1) [[COS_OUT]], align 4112; CHECK-NEXT: ret void113;114entry:115 %call = tail call contract float @_Z3sinf(float %x)116 store float %call, ptr addrspace(1) %sin_out, align 4117 %call1 = tail call contract float @_Z3cosf(float %x)118 store float %call1, ptr addrspace(1) %cos_out, align 4119 ret void120}121 122define void @sincos_f32_value_is_same_constantfp(ptr addrspace(1) nocapture writeonly %sin_out, ptr addrspace(1) nocapture writeonly %cos_out) {123; CHECK-LABEL: define void @sincos_f32_value_is_same_constantfp124; CHECK-SAME: (ptr addrspace(1) writeonly captures(none) [[SIN_OUT:%.*]], ptr addrspace(1) writeonly captures(none) [[COS_OUT:%.*]]) {125; CHECK-NEXT: entry:126; CHECK-NEXT: [[CALL:%.*]] = tail call contract float @_Z3sinf(float 4.200000e+01)127; CHECK-NEXT: store float [[CALL]], ptr addrspace(1) [[SIN_OUT]], align 4128; CHECK-NEXT: [[CALL1:%.*]] = tail call contract float @_Z3cosf(float 4.200000e+01)129; CHECK-NEXT: store float [[CALL1]], ptr addrspace(1) [[COS_OUT]], align 4130; CHECK-NEXT: ret void131;132entry:133 %call = tail call contract float @_Z3sinf(float 42.0)134 store float %call, ptr addrspace(1) %sin_out, align 4135 %call1 = tail call contract float @_Z3cosf(float 42.0)136 store float %call1, ptr addrspace(1) %cos_out, align 4137 ret void138}139 140define void @sincos_v2f32(<2 x float> %x, ptr addrspace(1) nocapture writeonly %sin_out, ptr addrspace(1) nocapture writeonly %cos_out) {141; GCN-LABEL: define void @sincos_v2f32142; GCN-SAME: (<2 x float> [[X:%.*]], ptr addrspace(1) nocapture writeonly [[SIN_OUT:%.*]], ptr addrspace(1) nocapture writeonly [[COS_OUT:%.*]]) local_unnamed_addr {143; GCN-NEXT: entry:144; GCN-NEXT: [[CALL:%.*]] = tail call contract <2 x float> @_Z3sinDv2_f(<2 x float> [[X]])145; GCN-NEXT: store <2 x float> [[CALL]], ptr addrspace(1) [[SIN_OUT]], align 8146; GCN-NEXT: [[CALL1:%.*]] = tail call contract <2 x float> @_Z3cosDv2_f(<2 x float> [[X]])147; GCN-NEXT: store <2 x float> [[CALL1]], ptr addrspace(1) [[COS_OUT]], align 8148; GCN-NEXT: ret void149;150; CHECK-LABEL: define void @sincos_v2f32151; CHECK-SAME: (<2 x float> [[X:%.*]], ptr addrspace(1) writeonly captures(none) [[SIN_OUT:%.*]], ptr addrspace(1) writeonly captures(none) [[COS_OUT:%.*]]) {152; CHECK-NEXT: entry:153; CHECK-NEXT: [[__SINCOS_:%.*]] = alloca <2 x float>, align 8, addrspace(5)154; CHECK-NEXT: [[TMP0:%.*]] = call contract <2 x float> @_Z6sincosDv2_fPU3AS5S_(<2 x float> [[X]], ptr addrspace(5) [[__SINCOS_]])155; CHECK-NEXT: [[TMP1:%.*]] = load <2 x float>, ptr addrspace(5) [[__SINCOS_]], align 8156; CHECK-NEXT: store <2 x float> [[TMP0]], ptr addrspace(1) [[SIN_OUT]], align 8157; CHECK-NEXT: [[CALL1:%.*]] = tail call contract <2 x float> @_Z3cosDv2_f(<2 x float> [[X]])158; CHECK-NEXT: store <2 x float> [[TMP1]], ptr addrspace(1) [[COS_OUT]], align 8159; CHECK-NEXT: ret void160;161entry:162 %call = tail call contract <2 x float> @_Z3sinDv2_f(<2 x float> %x)163 store <2 x float> %call, ptr addrspace(1) %sin_out, align 8164 %call1 = tail call contract <2 x float> @_Z3cosDv2_f(<2 x float> %x)165 store <2 x float> %call1, ptr addrspace(1) %cos_out, align 8166 ret void167}168 169define void @sincos_f32_nobuiltin_callsite(float %x, ptr addrspace(1) nocapture writeonly %sin_out, ptr addrspace(1) nocapture writeonly %cos_out) {170; CHECK-LABEL: define void @sincos_f32_nobuiltin_callsite171; CHECK-SAME: (float [[X:%.*]], ptr addrspace(1) writeonly captures(none) [[SIN_OUT:%.*]], ptr addrspace(1) writeonly captures(none) [[COS_OUT:%.*]]) {172; CHECK-NEXT: entry:173; CHECK-NEXT: [[CALL:%.*]] = tail call contract float @_Z3sinf(float [[X]]) #[[ATTR0:[0-9]+]]174; CHECK-NEXT: store float [[CALL]], ptr addrspace(1) [[SIN_OUT]], align 4175; CHECK-NEXT: [[CALL1:%.*]] = tail call contract float @_Z3cosf(float [[X]]) #[[ATTR0]]176; CHECK-NEXT: store float [[CALL1]], ptr addrspace(1) [[COS_OUT]], align 4177; CHECK-NEXT: ret void178;179entry:180 %call = tail call contract float @_Z3sinf(float %x) nobuiltin181 store float %call, ptr addrspace(1) %sin_out, align 4182 %call1 = tail call contract float @_Z3cosf(float %x) nobuiltin183 store float %call1, ptr addrspace(1) %cos_out, align 4184 ret void185}186