1 ; RUN: llc < %s -mtriple=i386-apple-darwin10 -mattr=+fma,-fma4 | FileCheck %s --check-prefix=CHECK-FMA-INST 2 ; RUN: llc < %s -mtriple=i386-apple-darwin10 -mattr=-fma,-fma4 | FileCheck %s --check-prefix=CHECK-FMA-CALL 3 ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -mattr=+fma,-fma4 | FileCheck %s --check-prefix=CHECK-FMA-INST 4 ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -mattr=-fma,-fma4 | FileCheck %s --check-prefix=CHECK-FMA-CALL 5 ; RUN: llc < %s -march=x86 -mcpu=bdver2 -mattr=-fma4 | FileCheck %s --check-prefix=CHECK-FMA-INST 6 ; RUN: llc < %s -march=x86 -mcpu=bdver2 -mattr=-fma,-fma4 | FileCheck %s --check-prefix=CHECK-FMA-CALL 7 8 ; CHECK: test_f32 9 ; CHECK-FMA-INST: vfmadd213ss 10 ; CHECK-FMA-CALL: fmaf 11 12 define float @test_f32(float %a, float %b, float %c) nounwind readnone ssp { 13 entry: 14 %call = tail call float @llvm.fma.f32(float %a, float %b, float %c) nounwind readnone 15 ret float %call 16 } 17 18 ; CHECK: test_f64 19 ; CHECK-FMA-INST: vfmadd213sd 20 ; CHECK-FMA-CALL: fma 21 22 define double @test_f64(double %a, double %b, double %c) nounwind readnone ssp { 23 entry: 24 %call = tail call double @llvm.fma.f64(double %a, double %b, double %c) nounwind readnone 25 ret double %call 26 } 27 28 ; CHECK: test_f80 29 ; CHECK: fmal 30 31 define x86_fp80 @test_f80(x86_fp80 %a, x86_fp80 %b, x86_fp80 %c) nounwind readnone ssp { 32 entry: 33 %call = tail call x86_fp80 @llvm.fma.f80(x86_fp80 %a, x86_fp80 %b, x86_fp80 %c) nounwind readnone 34 ret x86_fp80 %call 35 } 36 37 ; CHECK: test_f32_cst 38 ; CHECK-NOT: fma 39 define float @test_f32_cst() nounwind readnone ssp { 40 entry: 41 %call = tail call float @llvm.fma.f32(float 3.0, float 3.0, float 3.0) nounwind readnone 42 ret float %call 43 } 44 45 ; Test FMA3 variant selection 46 ; CHECK: fma3_select231ssX: 47 ; CHECK: vfmadd231ss xmm 48 define float @fma3_select231ssX(float %x, float %y) #0 { 49 entry: 50 br label %while.body 51 while.body: ; preds = %while.body, %while.body 52 %acc.01 = phi float [ 0.000000e+00, %entry ], [ %acc, %while.body ] 53 %acc = tail call float @llvm.fma.f32(float %x, float %y, float %acc.01) nounwind readnone 54 %b = fcmp ueq float %acc, 0.0 55 br i1 %b, label %while.body, label %while.end 56 while.end: ; preds = %while.body, %entry 57 ret float %acc 58 } 59 60 ; Test FMA3 variant selection 61 ; CHECK: fma3_select231pdY: 62 ; CHECK: vfmadd231pd ymm 63 define <4 x double> @fma3_select231pdY(<4 x double> %x, <4 x double> %y) #0 { 64 entry: 65 br label %while.body 66 while.body: ; preds = %entry, %while.body 67 %acc.04 = phi <4 x double> [ zeroinitializer, %entry ], [ %add, %while.body ] 68 %add = tail call <4 x double> @llvm.fma.v4f64(<4 x double> %x, <4 x double> %y, <4 x double> %acc.04) 69 %vecext = extractelement <4 x double> %add, i32 0 70 %cmp = fcmp oeq double %vecext, 0.000000e+00 71 br i1 %cmp, label %while.body, label %while.end 72 73 while.end: ; preds = %while.body 74 ret <4 x double> %add 75 } 76 77 declare float @llvm.fma.f32(float, float, float) nounwind readnone 78 declare double @llvm.fma.f64(double, double, double) nounwind readnone 79 declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) nounwind readnone 80 declare <4 x double> @llvm.fma.v4f64(<4 x double>, <4 x double>, <4 x double>) nounwind readnone 81