152 lines · plain
1; RUN: llc < %s -mtriple=ve | FileCheck %s2 3;;; Test ‘llvm.cos.*’ intrinsic4;;;5;;; Syntax:6;;; This is an overloaded intrinsic. You can use llvm.cos on any7;;; floating-point or vector of floating-point type. Not all targets8;;; support all types however.9;;;10;;; declare float @llvm.cos.f32(float %Val)11;;; declare double @llvm.cos.f64(double %Val)12;;; declare x86_fp80 @llvm.cos.f80(x86_fp80 %Val)13;;; declare fp128 @llvm.cos.f128(fp128 %Val)14;;; declare ppc_fp128 @llvm.cos.ppcf128(ppc_fp128 %Val)15;;;16;;; Overview:17;;; The ‘llvm.cos.*’ intrinsics return the cosine of the operand.18;;;19;;; Arguments:20;;; The argument and return value are floating-point numbers of the same type.21;;;22;;; Semantics:23;;; Return the same value as a corresponding libm ‘cos’ function but without24;;; trapping or setting errno.25;;;26;;; When specified with the fast-math-flag ‘afn’, the result may be27;;; approximated using a less accurate calculation.28;;;29;;; Note:30;;; We test only float/double/fp128.31 32; Function Attrs: nounwind readnone33define float @fcos_float_var(float %0) {34; CHECK-LABEL: fcos_float_var:35; CHECK: .LBB{{[0-9]+}}_2:36; CHECK-NEXT: lea %s1, cosf@lo37; CHECK-NEXT: and %s1, %s1, (32)038; CHECK-NEXT: lea.sl %s12, cosf@hi(, %s1)39; CHECK-NEXT: bsic %s10, (, %s12)40; CHECK-NEXT: or %s11, 0, %s941 %2 = tail call fast float @llvm.cos.f32(float %0)42 ret float %243}44 45; Function Attrs: nounwind readnone speculatable willreturn46declare float @llvm.cos.f32(float)47 48; Function Attrs: nounwind readnone49define double @fcos_double_var(double %0) {50; CHECK-LABEL: fcos_double_var:51; CHECK: .LBB{{[0-9]+}}_2:52; CHECK-NEXT: lea %s1, cos@lo53; CHECK-NEXT: and %s1, %s1, (32)054; CHECK-NEXT: lea.sl %s12, cos@hi(, %s1)55; CHECK-NEXT: bsic %s10, (, %s12)56; CHECK-NEXT: or %s11, 0, %s957 %2 = tail call fast double @llvm.cos.f64(double %0)58 ret double %259}60 61; Function Attrs: nounwind readnone speculatable willreturn62declare double @llvm.cos.f64(double)63 64; Function Attrs: nounwind readnone65define fp128 @fcos_quad_var(fp128 %0) {66; CHECK-LABEL: fcos_quad_var:67; CHECK: .LBB{{[0-9]+}}_2:68; CHECK-NEXT: lea %s2, cosl@lo69; CHECK-NEXT: and %s2, %s2, (32)070; CHECK-NEXT: lea.sl %s12, cosl@hi(, %s2)71; CHECK-NEXT: bsic %s10, (, %s12)72; CHECK-NEXT: or %s11, 0, %s973 %2 = tail call fast fp128 @llvm.cos.f128(fp128 %0)74 ret fp128 %275}76 77; Function Attrs: nounwind readnone speculatable willreturn78declare fp128 @llvm.cos.f128(fp128)79 80; Function Attrs: norecurse nounwind readnone81define float @fcos_float_zero() {82; CHECK-LABEL: fcos_float_zero:83; CHECK: # %bb.0:84; CHECK-NEXT: lea.sl %s0, 106535321685; CHECK-NEXT: b.l.t (, %s10)86 ret float 1.000000e+0087}88 89; Function Attrs: norecurse nounwind readnone90define double @fcos_double_zero() {91; CHECK-LABEL: fcos_double_zero:92; CHECK: # %bb.0:93; CHECK-NEXT: lea.sl %s0, 107269324894; CHECK-NEXT: b.l.t (, %s10)95 ret double 1.000000e+0096}97 98; Function Attrs: nounwind readnone99define fp128 @fcos_quad_zero() {100; CHECK-LABEL: fcos_quad_zero:101; CHECK: .LBB{{[0-9]+}}_2:102; CHECK-NEXT: lea %s0, .LCPI{{[0-9]+}}_0@lo103; CHECK-NEXT: and %s0, %s0, (32)0104; CHECK-NEXT: lea.sl %s2, .LCPI{{[0-9]+}}_0@hi(, %s0)105; CHECK-NEXT: ld %s0, 8(, %s2)106; CHECK-NEXT: ld %s1, (, %s2)107; CHECK-NEXT: lea %s2, cosl@lo108; CHECK-NEXT: and %s2, %s2, (32)0109; CHECK-NEXT: lea.sl %s12, cosl@hi(, %s2)110; CHECK-NEXT: bsic %s10, (, %s12)111; CHECK-NEXT: or %s11, 0, %s9112 %1 = tail call fast fp128 @llvm.cos.f128(fp128 0xL00000000000000000000000000000000)113 ret fp128 %1114}115 116; Function Attrs: norecurse nounwind readnone117define float @fcos_float_const() {118; CHECK-LABEL: fcos_float_const:119; CHECK: # %bb.0:120; CHECK-NEXT: lea.sl %s0, -1093332685121; CHECK-NEXT: b.l.t (, %s10)122 ret float 0xBFDAA22660000000123}124 125; Function Attrs: norecurse nounwind readnone126define double @fcos_double_const() {127; CHECK-LABEL: fcos_double_const:128; CHECK: # %bb.0:129; CHECK-NEXT: lea %s0, 1465086469130; CHECK-NEXT: lea.sl %s0, -1076190682(, %s0)131; CHECK-NEXT: b.l.t (, %s10)132 ret double 0xBFDAA22657537205133}134 135; Function Attrs: nounwind readnone136define fp128 @fcos_quad_const() {137; CHECK-LABEL: fcos_quad_const:138; CHECK: .LBB{{[0-9]+}}_2:139; CHECK-NEXT: lea %s0, .LCPI{{[0-9]+}}_0@lo140; CHECK-NEXT: and %s0, %s0, (32)0141; CHECK-NEXT: lea.sl %s2, .LCPI{{[0-9]+}}_0@hi(, %s0)142; CHECK-NEXT: ld %s0, 8(, %s2)143; CHECK-NEXT: ld %s1, (, %s2)144; CHECK-NEXT: lea %s2, cosl@lo145; CHECK-NEXT: and %s2, %s2, (32)0146; CHECK-NEXT: lea.sl %s12, cosl@hi(, %s2)147; CHECK-NEXT: bsic %s10, (, %s12)148; CHECK-NEXT: or %s11, 0, %s9149 %1 = tail call fast fp128 @llvm.cos.f128(fp128 0xL0000000000000000C000000000000000)150 ret fp128 %1151}152