237 lines · plain
1; RUN: llc < %s -mtriple=ve | FileCheck %s2 3;;; Test ‘llvm.fma.*’ intrinsic4;;;5;;; Syntax:6;;; This is an overloaded intrinsic. You can use llvm.fma on any7;;; floating-point or vector of floating-point type. Not all targets8;;; support all types however.9;;;10;;; declare float @llvm.fma.f32(float %a, float %b, float %c)11;;; declare double @llvm.fma.f64(double %a, double %b, double %c)12;;; declare x86_fp80 @llvm.fma.f80(x86_fp80 %a, x86_fp80 %b, x86_fp80 %c)13;;; declare fp128 @llvm.fma.f128(fp128 %a, fp128 %b, fp128 %c)14;;; declare ppc_fp128 @llvm.fma.ppcf128(ppc_fp128 %a, ppc_fp128 %b,15;;; ppc_fp128 %c)16;;;17;;; Overview:18;;; The ‘llvm.fma.*’ intrinsics perform the fused multiply-add operation.19;;;20;;; Arguments:21;;; The arguments and return value are floating-point numbers of the same22;;; type.23;;;24;;; Semantics:25;;; Return the same value as a corresponding libm ‘fma’ function but without26;;; trapping or setting errno.27;;;28;;; When specified with the fast-math-flag ‘afn’, the result may be29;;; approximated using a less accurate calculation.30;;;31;;; Note:32;;; We test only float/double/fp128.33 34; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn35define float @fma_float_var(float noundef %0, float noundef %1, float noundef %2) {36; CHECK-LABEL: fma_float_var:37; CHECK: .LBB{{[0-9]+}}_2:38; CHECK-NEXT: lea %s3, fmaf@lo39; CHECK-NEXT: and %s3, %s3, (32)040; CHECK-NEXT: lea.sl %s12, fmaf@hi(, %s3)41; CHECK-NEXT: bsic %s10, (, %s12)42; CHECK-NEXT: or %s11, 0, %s943 %4 = tail call fast float @llvm.fma.f32(float %0, float %1, float %2)44 ret float %445}46 47; Function Attrs: mustprogress nocallback nofree nosync nounwind readnone speculatable willreturn48declare float @llvm.fma.f32(float, float, float)49 50; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn51define double @fma_double_var(double noundef %0, double noundef %1, double noundef %2) {52; CHECK-LABEL: fma_double_var:53; CHECK: .LBB{{[0-9]+}}_2:54; CHECK-NEXT: lea %s3, fma@lo55; CHECK-NEXT: and %s3, %s3, (32)056; CHECK-NEXT: lea.sl %s12, fma@hi(, %s3)57; CHECK-NEXT: bsic %s10, (, %s12)58; CHECK-NEXT: or %s11, 0, %s959 %4 = tail call fast double @llvm.fma.f64(double %0, double %1, double %2)60 ret double %461}62 63; Function Attrs: mustprogress nocallback nofree nosync nounwind readnone speculatable willreturn64declare double @llvm.fma.f64(double, double, double)65 66; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn67define fp128 @fma_quad_var(fp128 noundef %0, fp128 noundef %1, fp128 noundef %2) {68; CHECK-LABEL: fma_quad_var:69; CHECK: .LBB{{[0-9]+}}_2:70; CHECK-NEXT: lea %s6, fmal@lo71; CHECK-NEXT: and %s6, %s6, (32)072; CHECK-NEXT: lea.sl %s12, fmal@hi(, %s6)73; CHECK-NEXT: bsic %s10, (, %s12)74; CHECK-NEXT: or %s11, 0, %s975 %4 = tail call fast fp128 @llvm.fma.f128(fp128 %0, fp128 %1, fp128 %2)76 ret fp128 %477}78 79; Function Attrs: mustprogress nocallback nofree nosync nounwind readnone speculatable willreturn80declare fp128 @llvm.fma.f128(fp128, fp128, fp128)81 82; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn83define float @fma_float_fore_zero(float noundef %0, float noundef returned %1) {84; CHECK-LABEL: fma_float_fore_zero:85; CHECK: # %bb.0:86; CHECK-NEXT: or %s0, 0, %s187; CHECK-NEXT: b.l.t (, %s10)88 ret float %189}90 91; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn92define double @fma_double_fore_zero(double noundef %0, double noundef returned %1) {93; CHECK-LABEL: fma_double_fore_zero:94; CHECK: # %bb.0:95; CHECK-NEXT: or %s0, 0, %s196; CHECK-NEXT: b.l.t (, %s10)97 ret double %198}99 100; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn101define fp128 @fma_quad_fore_zero(fp128 noundef %0, fp128 noundef returned %1) {102; CHECK-LABEL: fma_quad_fore_zero:103; CHECK: # %bb.0:104; CHECK-NEXT: or %s0, 0, %s2105; CHECK-NEXT: or %s1, 0, %s3106; CHECK-NEXT: b.l.t (, %s10)107 ret fp128 %1108}109 110; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn111define float @fma_float_back_zero(float noundef %0, float noundef returned %1) {112; CHECK-LABEL: fma_float_back_zero:113; CHECK: # %bb.0:114; CHECK-NEXT: or %s0, 0, %s1115; CHECK-NEXT: b.l.t (, %s10)116 ret float %1117}118 119; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn120define double @fma_double_back_zero(double noundef %0, double noundef returned %1) {121; CHECK-LABEL: fma_double_back_zero:122; CHECK: # %bb.0:123; CHECK-NEXT: or %s0, 0, %s1124; CHECK-NEXT: b.l.t (, %s10)125 ret double %1126}127 128; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn129define fp128 @fma_quad_back_zero(fp128 noundef %0, fp128 noundef returned %1) {130; CHECK-LABEL: fma_quad_back_zero:131; CHECK: # %bb.0:132; CHECK-NEXT: or %s0, 0, %s2133; CHECK-NEXT: or %s1, 0, %s3134; CHECK-NEXT: b.l.t (, %s10)135 ret fp128 %1136}137 138; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn139define float @fma_float_fore_const(float noundef %0, float noundef %1) {140; CHECK-LABEL: fma_float_fore_const:141; CHECK: .LBB{{[0-9]+}}_2:142; CHECK-NEXT: or %s2, 0, %s1143; CHECK-NEXT: lea %s1, fmaf@lo144; CHECK-NEXT: and %s1, %s1, (32)0145; CHECK-NEXT: lea.sl %s12, fmaf@hi(, %s1)146; CHECK-NEXT: lea.sl %s1, -1073741824147; CHECK-NEXT: bsic %s10, (, %s12)148; CHECK-NEXT: or %s11, 0, %s9149 %3 = tail call fast float @llvm.fma.f32(float %0, float -2.000000e+00, float %1)150 ret float %3151}152 153; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn154define double @fma_double_fore_const(double noundef %0, double noundef %1) {155; CHECK-LABEL: fma_double_fore_const:156; CHECK: .LBB{{[0-9]+}}_2:157; CHECK-NEXT: or %s2, 0, %s1158; CHECK-NEXT: lea %s1, fma@lo159; CHECK-NEXT: and %s1, %s1, (32)0160; CHECK-NEXT: lea.sl %s12, fma@hi(, %s1)161; CHECK-NEXT: lea.sl %s1, -1073741824162; CHECK-NEXT: bsic %s10, (, %s12)163; CHECK-NEXT: or %s11, 0, %s9164 %3 = tail call fast double @llvm.fma.f64(double %0, double -2.000000e+00, double %1)165 ret double %3166}167 168; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn169define fp128 @fma_quad_fore_const(fp128 noundef %0, fp128 noundef %1) {170; CHECK-LABEL: fma_quad_fore_const:171; CHECK: .LBB{{[0-9]+}}_2:172; CHECK-NEXT: or %s4, 0, %s2173; CHECK-NEXT: or %s5, 0, %s3174; CHECK-NEXT: lea %s2, .LCPI{{[0-9]+}}_0@lo175; CHECK-NEXT: and %s2, %s2, (32)0176; CHECK-NEXT: lea.sl %s6, .LCPI{{[0-9]+}}_0@hi(, %s2)177; CHECK-NEXT: ld %s2, 8(, %s6)178; CHECK-NEXT: ld %s3, (, %s6)179; CHECK-NEXT: lea %s6, fmal@lo180; CHECK-NEXT: and %s6, %s6, (32)0181; CHECK-NEXT: lea.sl %s12, fmal@hi(, %s6)182; CHECK-NEXT: bsic %s10, (, %s12)183; CHECK-NEXT: or %s11, 0, %s9184 %3 = tail call fast fp128 @llvm.fma.f128(fp128 %0, fp128 0xL0000000000000000C000000000000000, fp128 %1)185 ret fp128 %3186}187 188; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn189define float @fma_float_back_const(float noundef %0, float noundef %1) {190; CHECK-LABEL: fma_float_back_const:191; CHECK: .LBB{{[0-9]+}}_2:192; CHECK-NEXT: or %s2, 0, %s1193; CHECK-NEXT: lea %s1, fmaf@lo194; CHECK-NEXT: and %s1, %s1, (32)0195; CHECK-NEXT: lea.sl %s12, fmaf@hi(, %s1)196; CHECK-NEXT: lea.sl %s1, -1073741824197; CHECK-NEXT: bsic %s10, (, %s12)198; CHECK-NEXT: or %s11, 0, %s9199 %3 = tail call fast float @llvm.fma.f32(float %0, float -2.000000e+00, float %1)200 ret float %3201}202 203; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn204define double @fma_double_back_const(double noundef %0, double noundef %1) {205; CHECK-LABEL: fma_double_back_const:206; CHECK: .LBB{{[0-9]+}}_2:207; CHECK-NEXT: or %s2, 0, %s1208; CHECK-NEXT: lea %s1, fma@lo209; CHECK-NEXT: and %s1, %s1, (32)0210; CHECK-NEXT: lea.sl %s12, fma@hi(, %s1)211; CHECK-NEXT: lea.sl %s1, -1073741824212; CHECK-NEXT: bsic %s10, (, %s12)213; CHECK-NEXT: or %s11, 0, %s9214 %3 = tail call fast double @llvm.fma.f64(double %0, double -2.000000e+00, double %1)215 ret double %3216}217 218; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn219define fp128 @fma_quad_back_const(fp128 noundef %0, fp128 noundef %1) {220; CHECK-LABEL: fma_quad_back_const:221; CHECK: .LBB{{[0-9]+}}_2:222; CHECK-NEXT: or %s4, 0, %s2223; CHECK-NEXT: or %s5, 0, %s3224; CHECK-NEXT: lea %s2, .LCPI{{[0-9]+}}_0@lo225; CHECK-NEXT: and %s2, %s2, (32)0226; CHECK-NEXT: lea.sl %s6, .LCPI{{[0-9]+}}_0@hi(, %s2)227; CHECK-NEXT: ld %s2, 8(, %s6)228; CHECK-NEXT: ld %s3, (, %s6)229; CHECK-NEXT: lea %s6, fmal@lo230; CHECK-NEXT: and %s6, %s6, (32)0231; CHECK-NEXT: lea.sl %s12, fmal@hi(, %s6)232; CHECK-NEXT: bsic %s10, (, %s12)233; CHECK-NEXT: or %s11, 0, %s9234 %3 = tail call fast fp128 @llvm.fma.f128(fp128 %0, fp128 0xL0000000000000000C000000000000000, fp128 %1)235 ret fp128 %3236}237