[llvm] r205206 - ARM64: add more patterns for commuted fmsub operations.

Tim Northover tnorthover at apple.com
Mon Mar 31 08:46:34 PDT 2014


Author: tnorthover
Date: Mon Mar 31 10:46:34 2014
New Revision: 205206

URL: http://llvm.org/viewvc/llvm-project?rev=205206&view=rev
Log:
ARM64: add more patterns for commuted fmsub operations.

Modified:
    llvm/trunk/lib/Target/ARM64/ARM64InstrInfo.td
    llvm/trunk/test/CodeGen/ARM64/fmadd.ll

Modified: llvm/trunk/lib/Target/ARM64/ARM64InstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM64/ARM64InstrInfo.td?rev=205206&r1=205205&r2=205206&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM64/ARM64InstrInfo.td (original)
+++ llvm/trunk/lib/Target/ARM64/ARM64InstrInfo.td Mon Mar 31 10:46:34 2014
@@ -1997,6 +1997,14 @@ defm FNMADD : ThreeOperandFPData<1, 0, "
 defm FNMSUB : ThreeOperandFPData<1, 1, "fnmsub",
      TriOpFrag<(fma node:$LHS, node:$MHS, (fneg node:$RHS))> >;
 
+// The following def pats catch the case where the LHS of an FMA is negated.
+// The TriOpFrag above catches the case where the middle operand is negated.
+def : Pat<(f32 (fma (fneg FPR32:$Rn), FPR32:$Rm, FPR32:$Rd)),
+          (FMSUBSrrr FPR32:$Rd, FPR32:$Rn, FPR32:$Rm)>;
+
+def : Pat<(f64 (fma (fneg FPR64:$Rn), FPR64:$Rm, FPR64:$Rd)),
+          (FMSUBDrrr FPR64:$Rd, FPR64:$Rn, FPR64:$Rm)>;
+
 //===----------------------------------------------------------------------===//
 // Floating point comparison instructions.
 //===----------------------------------------------------------------------===//

Modified: llvm/trunk/test/CodeGen/ARM64/fmadd.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM64/fmadd.ll?rev=205206&r1=205205&r2=205206&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM64/fmadd.ll (original)
+++ llvm/trunk/test/CodeGen/ARM64/fmadd.ll Mon Mar 31 10:46:34 2014
@@ -26,6 +26,15 @@ entry:
   ret float %0
 }
 
+define float @fms32_com(float %a, float %b, float %c) nounwind readnone ssp {
+entry:
+; CHECK-LABEL: fms32_com:
+; CHECK: fmsub
+  %mul = fmul float %b, -1.000000e+00
+  %0 = tail call float @llvm.fma.f32(float %mul, float %a, float %c)
+  ret float %0
+}
+
 define float @fnms32(float %a, float %b, float %c) nounwind readnone ssp {
 entry:
 ; CHECK-LABEL: fnms32:
@@ -61,6 +70,15 @@ entry:
   ret double %0
 }
 
+define double @fms64_com(double %a, double %b, double %c) nounwind readnone ssp {
+; CHECK-LABEL: fms64_com:
+; CHECK: fmsub
+entry:
+  %mul = fmul double %b, -1.000000e+00
+  %0 = tail call double @llvm.fma.f64(double %mul, double %a, double %c)
+  ret double %0
+}
+
 define double @fnms64(double %a, double %b, double %c) nounwind readnone ssp {
 ; CHECK-LABEL: fnms64:
 ; CHECK: fnmsub





More information about the llvm-commits mailing list