205 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc --mtriple=loongarch32 --mattr=+d < %s | FileCheck %s --check-prefix=LA323; RUN: llc --mtriple=loongarch64 --mattr=+d < %s | FileCheck %s --check-prefix=LA644 5;; TODO: Add more test cases after ABI implementation for ilp32f and lp64f.6 7declare float @llvm.sin.f32(float)8declare float @llvm.cos.f32(float)9declare float @llvm.pow.f32(float, float)10declare double @llvm.sin.f64(double)11declare double @llvm.cos.f64(double)12declare double @llvm.pow.f64(double, double)13 14define float @sin_f32(float %a) nounwind {15; LA32-LABEL: sin_f32:16; LA32: # %bb.0:17; LA32-NEXT: b sinf18;19; LA64-LABEL: sin_f32:20; LA64: # %bb.0:21; LA64-NEXT: pcaddu18i $t8, %call36(sinf)22; LA64-NEXT: jr $t823 %1 = call float @llvm.sin.f32(float %a)24 ret float %125}26 27define float @cos_f32(float %a) nounwind {28; LA32-LABEL: cos_f32:29; LA32: # %bb.0:30; LA32-NEXT: b cosf31;32; LA64-LABEL: cos_f32:33; LA64: # %bb.0:34; LA64-NEXT: pcaddu18i $t8, %call36(cosf)35; LA64-NEXT: jr $t836 %1 = call float @llvm.cos.f32(float %a)37 ret float %138}39 40define float @sincos_f32(float %a) nounwind {41; LA32-LABEL: sincos_f32:42; LA32: # %bb.0:43; LA32-NEXT: addi.w $sp, $sp, -3244; LA32-NEXT: st.w $ra, $sp, 28 # 4-byte Folded Spill45; LA32-NEXT: fst.d $fs0, $sp, 16 # 8-byte Folded Spill46; LA32-NEXT: fst.d $fs1, $sp, 8 # 8-byte Folded Spill47; LA32-NEXT: fmov.s $fs0, $fa048; LA32-NEXT: bl sinf49; LA32-NEXT: fmov.s $fs1, $fa050; LA32-NEXT: fmov.s $fa0, $fs051; LA32-NEXT: bl cosf52; LA32-NEXT: fadd.s $fa0, $fs1, $fa053; LA32-NEXT: fld.d $fs1, $sp, 8 # 8-byte Folded Reload54; LA32-NEXT: fld.d $fs0, $sp, 16 # 8-byte Folded Reload55; LA32-NEXT: ld.w $ra, $sp, 28 # 4-byte Folded Reload56; LA32-NEXT: addi.w $sp, $sp, 3257; LA32-NEXT: ret58;59; LA64-LABEL: sincos_f32:60; LA64: # %bb.0:61; LA64-NEXT: addi.d $sp, $sp, -3262; LA64-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill63; LA64-NEXT: fst.d $fs0, $sp, 16 # 8-byte Folded Spill64; LA64-NEXT: fst.d $fs1, $sp, 8 # 8-byte Folded Spill65; LA64-NEXT: fmov.s $fs0, $fa066; LA64-NEXT: pcaddu18i $ra, %call36(sinf)67; LA64-NEXT: jirl $ra, $ra, 068; LA64-NEXT: fmov.s $fs1, $fa069; LA64-NEXT: fmov.s $fa0, $fs070; LA64-NEXT: pcaddu18i $ra, %call36(cosf)71; LA64-NEXT: jirl $ra, $ra, 072; LA64-NEXT: fadd.s $fa0, $fs1, $fa073; LA64-NEXT: fld.d $fs1, $sp, 8 # 8-byte Folded Reload74; LA64-NEXT: fld.d $fs0, $sp, 16 # 8-byte Folded Reload75; LA64-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload76; LA64-NEXT: addi.d $sp, $sp, 3277; LA64-NEXT: ret78 %1 = call float @llvm.sin.f32(float %a)79 %2 = call float @llvm.cos.f32(float %a)80 %3 = fadd float %1, %281 ret float %382}83 84define float @pow_f32(float %a, float %b) nounwind {85; LA32-LABEL: pow_f32:86; LA32: # %bb.0:87; LA32-NEXT: b powf88;89; LA64-LABEL: pow_f32:90; LA64: # %bb.0:91; LA64-NEXT: pcaddu18i $t8, %call36(powf)92; LA64-NEXT: jr $t893 %1 = call float @llvm.pow.f32(float %a, float %b)94 ret float %195}96 97define float @frem_f32(float %a, float %b) nounwind {98; LA32-LABEL: frem_f32:99; LA32: # %bb.0:100; LA32-NEXT: b fmodf101;102; LA64-LABEL: frem_f32:103; LA64: # %bb.0:104; LA64-NEXT: pcaddu18i $t8, %call36(fmodf)105; LA64-NEXT: jr $t8106 %1 = frem float %a, %b107 ret float %1108}109 110define double @sin_f64(double %a) nounwind {111; LA32-LABEL: sin_f64:112; LA32: # %bb.0:113; LA32-NEXT: b sin114;115; LA64-LABEL: sin_f64:116; LA64: # %bb.0:117; LA64-NEXT: pcaddu18i $t8, %call36(sin)118; LA64-NEXT: jr $t8119 %1 = call double @llvm.sin.f64(double %a)120 ret double %1121}122 123define double @cos_f64(double %a) nounwind {124; LA32-LABEL: cos_f64:125; LA32: # %bb.0:126; LA32-NEXT: b cos127;128; LA64-LABEL: cos_f64:129; LA64: # %bb.0:130; LA64-NEXT: pcaddu18i $t8, %call36(cos)131; LA64-NEXT: jr $t8132 %1 = call double @llvm.cos.f64(double %a)133 ret double %1134}135 136define double @sincos_f64(double %a) nounwind {137; LA32-LABEL: sincos_f64:138; LA32: # %bb.0:139; LA32-NEXT: addi.w $sp, $sp, -32140; LA32-NEXT: st.w $ra, $sp, 28 # 4-byte Folded Spill141; LA32-NEXT: fst.d $fs0, $sp, 16 # 8-byte Folded Spill142; LA32-NEXT: fst.d $fs1, $sp, 8 # 8-byte Folded Spill143; LA32-NEXT: fmov.d $fs0, $fa0144; LA32-NEXT: bl sin145; LA32-NEXT: fmov.d $fs1, $fa0146; LA32-NEXT: fmov.d $fa0, $fs0147; LA32-NEXT: bl cos148; LA32-NEXT: fadd.d $fa0, $fs1, $fa0149; LA32-NEXT: fld.d $fs1, $sp, 8 # 8-byte Folded Reload150; LA32-NEXT: fld.d $fs0, $sp, 16 # 8-byte Folded Reload151; LA32-NEXT: ld.w $ra, $sp, 28 # 4-byte Folded Reload152; LA32-NEXT: addi.w $sp, $sp, 32153; LA32-NEXT: ret154;155; LA64-LABEL: sincos_f64:156; LA64: # %bb.0:157; LA64-NEXT: addi.d $sp, $sp, -32158; LA64-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill159; LA64-NEXT: fst.d $fs0, $sp, 16 # 8-byte Folded Spill160; LA64-NEXT: fst.d $fs1, $sp, 8 # 8-byte Folded Spill161; LA64-NEXT: fmov.d $fs0, $fa0162; LA64-NEXT: pcaddu18i $ra, %call36(sin)163; LA64-NEXT: jirl $ra, $ra, 0164; LA64-NEXT: fmov.d $fs1, $fa0165; LA64-NEXT: fmov.d $fa0, $fs0166; LA64-NEXT: pcaddu18i $ra, %call36(cos)167; LA64-NEXT: jirl $ra, $ra, 0168; LA64-NEXT: fadd.d $fa0, $fs1, $fa0169; LA64-NEXT: fld.d $fs1, $sp, 8 # 8-byte Folded Reload170; LA64-NEXT: fld.d $fs0, $sp, 16 # 8-byte Folded Reload171; LA64-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload172; LA64-NEXT: addi.d $sp, $sp, 32173; LA64-NEXT: ret174 %1 = call double @llvm.sin.f64(double %a)175 %2 = call double @llvm.cos.f64(double %a)176 %3 = fadd double %1, %2177 ret double %3178}179 180define double @pow_f64(double %a, double %b) nounwind {181; LA32-LABEL: pow_f64:182; LA32: # %bb.0:183; LA32-NEXT: b pow184;185; LA64-LABEL: pow_f64:186; LA64: # %bb.0:187; LA64-NEXT: pcaddu18i $t8, %call36(pow)188; LA64-NEXT: jr $t8189 %1 = call double @llvm.pow.f64(double %a, double %b)190 ret double %1191}192 193define double @frem_f64(double %a, double %b) nounwind {194; LA32-LABEL: frem_f64:195; LA32: # %bb.0:196; LA32-NEXT: b fmod197;198; LA64-LABEL: frem_f64:199; LA64: # %bb.0:200; LA64-NEXT: pcaddu18i $t8, %call36(fmod)201; LA64-NEXT: jr $t8202 %1 = frem double %a, %b203 ret double %1204}205