[llvm-commits] [llvm] r157707 - in /llvm/trunk: lib/CodeGen/SelectionDAG/DAGCombiner.cpp test/CodeGen/ARM/fusedMAC.ll
Owen Anderson
resistor at mac.com
Wed May 30 11:50:39 PDT 2012
Author: resistor
Date: Wed May 30 13:50:39 2012
New Revision: 157707
URL: http://llvm.org/viewvc/llvm-project?rev=157707&view=rev
Log:
Teach DAGCombine to canonicalize the position of a constant in the term operands of an FMA node.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/trunk/test/CodeGen/ARM/fusedMAC.ll
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=157707&r1=157706&r2=157707&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Wed May 30 13:50:39 2012
@@ -5770,6 +5770,10 @@
if (N1CFP && N1CFP->isExactlyValue(1.0))
return DAG.getNode(ISD::FADD, N->getDebugLoc(), VT, N0, N2);
+ // Canonicalize (fma c, x, y) -> (fma x, c, y)
+ if (!N0CFP && N1CFP)
+ return DAG.getNode(ISD::FMA, N->getDebugLoc(), VT, N1, N0, N2);
+
return SDValue();
}
Modified: llvm/trunk/test/CodeGen/ARM/fusedMAC.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fusedMAC.ll?rev=157707&r1=157706&r2=157707&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/fusedMAC.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/fusedMAC.ll Wed May 30 13:50:39 2012
@@ -189,6 +189,15 @@
ret float %ret
}
+define float @test_fma_canonicalize(float %a, float %b) nounwind {
+; CHECK: test_fma_canonicalize
+; CHECK: vmov.f32 s0
+; CHECK: vfma.f32 s2, s0, s1
+ %ret = call float @llvm.fma.f32(float 2.0, float %a, float %b)
+ ret float %ret
+}
+
+
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