[llvm-commits] [llvm] r154469 - in /llvm/trunk: lib/Target/ARM/ARMInstrVFP.td test/CodeGen/ARM/fusedMAC.ll

Evan Cheng evan.cheng at apple.com
Tue Apr 10 18:21:26 PDT 2012


Author: evancheng
Date: Tue Apr 10 20:21:25 2012
New Revision: 154469

URL: http://llvm.org/viewvc/llvm-project?rev=154469&view=rev
Log:
Match (fneg (fma) to vfnma. rdar://10139676

Modified:
    llvm/trunk/lib/Target/ARM/ARMInstrVFP.td
    llvm/trunk/test/CodeGen/ARM/fusedMAC.ll

Modified: llvm/trunk/lib/Target/ARM/ARMInstrVFP.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrVFP.td?rev=154469&r1=154468&r2=154469&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMInstrVFP.td (original)
+++ llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Tue Apr 10 20:21:25 2012
@@ -1140,6 +1140,14 @@
           (VFNMAS SPR:$dstin, SPR:$a, SPR:$b)>,
           Requires<[HasVFP4,DontUseNEONForFP,FPContractions]>;
 
+// Match @llvm.fma.* intrinsics
+def : Pat<(fneg (fma (f64 DPR:$Ddin), (f64 DPR:$Dn), (f64 DPR:$Dm))),
+          (VFNMAD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>,
+      Requires<[HasVFP4]>;
+def : Pat<(fneg (fma (f32 SPR:$Sdin), (f32 SPR:$Sn), (f32 SPR:$Sm))),
+          (VFNMAS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>,
+      Requires<[HasVFP4]>;
+
 def VFNMSD : ADbI<0b11101, 0b01, 0, 0,
                   (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
                   IIC_fpFMAC64, "vfnms", ".f64\t$Dd, $Dn, $Dm",

Modified: llvm/trunk/test/CodeGen/ARM/fusedMAC.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fusedMAC.ll?rev=154469&r1=154468&r2=154469&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/fusedMAC.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/fusedMAC.ll Tue Apr 10 20:21:25 2012
@@ -99,30 +99,49 @@
   ret <4 x float> %sub
 }
 
-define float @test_f32(float %a, float %b, float %c) nounwind readnone ssp {
+define float @test_fma_f32(float %a, float %b, float %c) nounwind readnone ssp {
 entry:
-; CHECK: test_f32
+; CHECK: test_fma_f32
 ; CHECK: vfma.f32
   %call = tail call float @llvm.fma.f32(float %a, float %b, float %c) nounwind readnone
   ret float %call
 }
 
-define double @test_f64(double %a, double %b, double %c) nounwind readnone ssp {
+define double @test_fma_f64(double %a, double %b, double %c) nounwind readnone ssp {
 entry:
-; CHECK: test_f64
+; CHECK: test_fma_f64
 ; CHECK: vfma.f64
   %call = tail call double @llvm.fma.f64(double %a, double %b, double %c) nounwind readnone
   ret double %call
 }
 
-define <2 x float> @test_v2f32(<2 x float> %a, <2 x float> %b, <2 x float> %c) nounwind readnone ssp {
+define <2 x float> @test_fma_v2f32(<2 x float> %a, <2 x float> %b, <2 x float> %c) nounwind readnone ssp {
 entry:
-; CHECK: test_v2f32
+; CHECK: test_fma_v2f32
 ; CHECK: vfma.f32
   %0 = tail call <2 x float> @llvm.fma.v2f32(<2 x float> %a, <2 x float> %b, <2 x float> %c) nounwind
   ret <2 x float> %0
 }
 
+define float @test_fnma_f32(float %a, float %b, float %c) nounwind readnone ssp {
+entry:
+; CHECK: test_fnma_f32
+; CHECK: vfnma.f32
+  %call = tail call float @llvm.fma.f32(float %a, float %b, float %c) nounwind readnone
+  %tmp1 = fsub float -0.0, %call
+  %tmp2 = fsub float %tmp1, %c
+  ret float %tmp2
+}
+
+define double @test_fnma_f64(double %a, double %b, double %c) nounwind readnone ssp {
+entry:
+; CHECK: test_fnma_f64
+; CHECK: vfnma.f64
+  %call = tail call double @llvm.fma.f64(double %a, double %b, double %c) nounwind readnone
+  %tmp = fsub double -0.0, %call
+  ret double %tmp
+}
+
 declare float @llvm.fma.f32(float, float, float) nounwind readnone
 declare double @llvm.fma.f64(double, double, double) nounwind readnone
 declare <2 x float> @llvm.fma.v2f32(<2 x float>, <2 x float>, <2 x float>) nounwind readnone





More information about the llvm-commits mailing list