1; RUN: llc -mtriple=arm64-eabi < %s | FileCheck %s 2 3define float @fma32(float %a, float %b, float %c) nounwind readnone ssp { 4entry: 5; CHECK-LABEL: fma32: 6; CHECK: fmadd s0, s0, s1, s2 7 %0 = tail call float @llvm.fma.f32(float %a, float %b, float %c) 8 ret float %0 9} 10 11define float @fnma32(float %a, float %b, float %c) nounwind readnone ssp { 12entry: 13; CHECK-LABEL: fnma32: 14; CHECK: fnmadd s0, s0, s1, s2 15 %0 = tail call float @llvm.fma.f32(float %a, float %b, float %c) 16 %mul = fmul float %0, -1.000000e+00 17 ret float %mul 18} 19 20define float @fms32(float %a, float %b, float %c) nounwind readnone ssp { 21entry: 22; CHECK-LABEL: fms32: 23; CHECK: fmsub s0, s0, s1, s2 24 %mul = fmul float %b, -1.000000e+00 25 %0 = tail call float @llvm.fma.f32(float %a, float %mul, float %c) 26 ret float %0 27} 28 29define float @fms32_com(float %a, float %b, float %c) nounwind readnone ssp { 30entry: 31; CHECK-LABEL: fms32_com: 32; CHECK: fmsub s0, s1, s0, s2 33 %mul = fmul float %b, -1.000000e+00 34 %0 = tail call float @llvm.fma.f32(float %mul, float %a, float %c) 35 ret float %0 36} 37 38define float @fnms32(float %a, float %b, float %c) nounwind readnone ssp { 39entry: 40; CHECK-LABEL: fnms32: 41; CHECK: fnmsub s0, s0, s1, s2 42 %mul = fmul float %c, -1.000000e+00 43 %0 = tail call float @llvm.fma.f32(float %a, float %b, float %mul) 44 ret float %0 45} 46 47define double @fma64(double %a, double %b, double %c) nounwind readnone ssp { 48; CHECK-LABEL: fma64: 49; CHECK: fmadd d0, d0, d1, d2 50entry: 51 %0 = tail call double @llvm.fma.f64(double %a, double %b, double %c) 52 ret double %0 53} 54 55define double @fnma64(double %a, double %b, double %c) nounwind readnone ssp { 56; CHECK-LABEL: fnma64: 57; CHECK: fnmadd d0, d0, d1, d2 58entry: 59 %0 = tail call double @llvm.fma.f64(double %a, double %b, double %c) 60 %mul = fmul double %0, -1.000000e+00 61 ret double %mul 62} 63 64define double @fms64(double %a, double %b, double %c) nounwind readnone ssp { 65; CHECK-LABEL: fms64: 66; CHECK: fmsub d0, d0, d1, d2 67entry: 68 %mul = fmul double %b, -1.000000e+00 69 %0 = tail call double @llvm.fma.f64(double %a, double %mul, double %c) 70 ret double %0 71} 72 73define double @fms64_com(double %a, double %b, double %c) nounwind readnone ssp { 74; CHECK-LABEL: fms64_com: 75; CHECK: fmsub d0, d1, d0, d2 76entry: 77 %mul = fmul double %b, -1.000000e+00 78 %0 = tail call double @llvm.fma.f64(double %mul, double %a, double %c) 79 ret double %0 80} 81 82define double @fnms64(double %a, double %b, double %c) nounwind readnone ssp { 83; CHECK-LABEL: fnms64: 84; CHECK: fnmsub d0, d0, d1, d2 85entry: 86 %mul = fmul double %c, -1.000000e+00 87 %0 = tail call double @llvm.fma.f64(double %a, double %b, double %mul) 88 ret double %0 89} 90 91; This would crash while trying getNegatedExpression(). 92 93define float @negated_constant(float %x) { 94; CHECK-LABEL: negated_constant: 95; CHECK: // %bb.0: 96; CHECK-NEXT: mov w8, #-1037565952 97; CHECK-NEXT: mov w9, #1109917696 98; CHECK-NEXT: fmov s1, w8 99; CHECK-NEXT: fmul s1, s0, s1 100; CHECK-NEXT: fmov s2, w9 101; CHECK-NEXT: fmadd s0, s0, s2, s1 102; CHECK-NEXT: ret 103 %m = fmul float %x, 42.0 104 %fma = call nsz float @llvm.fma.f32(float %x, float -42.0, float %m) 105 %nfma = fneg float %fma 106 ret float %nfma 107} 108 109declare float @llvm.fma.f32(float, float, float) nounwind readnone 110declare double @llvm.fma.f64(double, double, double) nounwind readnone 111