152 lines · plain
1; RUN: llc < %s -mtriple=ve | FileCheck %s2 3;;; Test ‘llvm.sqrt.*’ intrinsic4;;;5;;; Syntax:6;;; This is an overloaded intrinsic. You can use llvm.sqrt on any7;;; floating-point or vector of floating-point type. Not all targets8;;; support all types however.9;;;10;;; declare float @llvm.sqrt.f32(float %Val)11;;; declare double @llvm.sqrt.f64(double %Val)12;;; declare x86_fp80 @llvm.sqrt.f80(x86_fp80 %Val)13;;; declare fp128 @llvm.sqrt.f128(fp128 %Val)14;;; declare ppc_fp128 @llvm.sqrt.ppcf128(ppc_fp128 %Val)15;;;16;;; Overview:17;;; The ‘llvm.sqrt’ intrinsics return the square root of the specified value.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 ‘sqrt’ function but without24;;; trapping or setting errno. For types specified by IEEE-754, the result25;;; matches a conforming libm implementation.26;;;27;;; When specified with the fast-math-flag ‘afn’, the result may be28;;; approximated using a less accurate calculation.29;;;30;;; Note:31;;; We test only float/double/fp128.32 33; Function Attrs: nounwind readnone34define float @fsqrt_float_var(float %0) {35; CHECK-LABEL: fsqrt_float_var:36; CHECK: .LBB{{[0-9]+}}_2:37; CHECK-NEXT: lea %s1, sqrtf@lo38; CHECK-NEXT: and %s1, %s1, (32)039; CHECK-NEXT: lea.sl %s12, sqrtf@hi(, %s1)40; CHECK-NEXT: bsic %s10, (, %s12)41; CHECK-NEXT: or %s11, 0, %s942 %2 = tail call fast float @llvm.sqrt.f32(float %0)43 ret float %244}45 46; Function Attrs: nounwind readnone speculatable willreturn47declare float @llvm.sqrt.f32(float)48 49; Function Attrs: nounwind readnone50define double @fsqrt_double_var(double %0) {51; CHECK-LABEL: fsqrt_double_var:52; CHECK: .LBB{{[0-9]+}}_2:53; CHECK-NEXT: lea %s1, sqrt@lo54; CHECK-NEXT: and %s1, %s1, (32)055; CHECK-NEXT: lea.sl %s12, sqrt@hi(, %s1)56; CHECK-NEXT: bsic %s10, (, %s12)57; CHECK-NEXT: or %s11, 0, %s958 %2 = tail call fast double @llvm.sqrt.f64(double %0)59 ret double %260}61 62; Function Attrs: nounwind readnone speculatable willreturn63declare double @llvm.sqrt.f64(double)64 65; Function Attrs: nounwind readnone66define fp128 @fsqrt_quad_var(fp128 %0) {67; CHECK-LABEL: fsqrt_quad_var:68; CHECK: .LBB{{[0-9]+}}_2:69; CHECK-NEXT: lea %s2, sqrtl@lo70; CHECK-NEXT: and %s2, %s2, (32)071; CHECK-NEXT: lea.sl %s12, sqrtl@hi(, %s2)72; CHECK-NEXT: bsic %s10, (, %s12)73; CHECK-NEXT: or %s11, 0, %s974 %2 = tail call fast fp128 @llvm.sqrt.f128(fp128 %0)75 ret fp128 %276}77 78; Function Attrs: nounwind readnone speculatable willreturn79declare fp128 @llvm.sqrt.f128(fp128)80 81; Function Attrs: norecurse nounwind readnone82define float @fsqrt_float_zero() {83; CHECK-LABEL: fsqrt_float_zero:84; CHECK: # %bb.0:85; CHECK-NEXT: lea.sl %s0, 086; CHECK-NEXT: b.l.t (, %s10)87 ret float 0.000000e+0088}89 90; Function Attrs: norecurse nounwind readnone91define double @fsqrt_double_zero() {92; CHECK-LABEL: fsqrt_double_zero:93; CHECK: # %bb.0:94; CHECK-NEXT: lea.sl %s0, 095; CHECK-NEXT: b.l.t (, %s10)96 ret double 0.000000e+0097}98 99; Function Attrs: nounwind readnone100define fp128 @fsqrt_quad_zero() {101; CHECK-LABEL: fsqrt_quad_zero:102; CHECK: .LBB{{[0-9]+}}_2:103; CHECK-NEXT: lea %s0, .LCPI{{[0-9]+}}_0@lo104; CHECK-NEXT: and %s0, %s0, (32)0105; CHECK-NEXT: lea.sl %s2, .LCPI{{[0-9]+}}_0@hi(, %s0)106; CHECK-NEXT: ld %s0, 8(, %s2)107; CHECK-NEXT: ld %s1, (, %s2)108; CHECK-NEXT: lea %s2, sqrtl@lo109; CHECK-NEXT: and %s2, %s2, (32)0110; CHECK-NEXT: lea.sl %s12, sqrtl@hi(, %s2)111; CHECK-NEXT: bsic %s10, (, %s12)112; CHECK-NEXT: or %s11, 0, %s9113 %1 = tail call fast fp128 @llvm.sqrt.f128(fp128 0xL00000000000000000000000000000000)114 ret fp128 %1115}116 117; Function Attrs: norecurse nounwind readnone118define float @fsqrt_float_const() {119; CHECK-LABEL: fsqrt_float_const:120; CHECK: # %bb.0:121; CHECK-NEXT: lea.sl %s0, -4194304122; CHECK-NEXT: b.l.t (, %s10)123 ret float 0xFFF8000000000000124}125 126; Function Attrs: norecurse nounwind readnone127define double @fsqrt_double_const() {128; CHECK-LABEL: fsqrt_double_const:129; CHECK: # %bb.0:130; CHECK-NEXT: lea.sl %s0, -524288131; CHECK-NEXT: b.l.t (, %s10)132 ret double 0xFFF8000000000000133}134 135; Function Attrs: nounwind readnone136define fp128 @fsqrt_quad_const() {137; CHECK-LABEL: fsqrt_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, sqrtl@lo145; CHECK-NEXT: and %s2, %s2, (32)0146; CHECK-NEXT: lea.sl %s12, sqrtl@hi(, %s2)147; CHECK-NEXT: bsic %s10, (, %s12)148; CHECK-NEXT: or %s11, 0, %s9149 %1 = tail call fast fp128 @llvm.sqrt.f128(fp128 0xL0000000000000000C000000000000000)150 ret fp128 %1151}152