From 0545df21497a7e3dab190b42b7cde840c9439395 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Sat, 3 May 2008 10:01:30 +0000 Subject: [PATCH] slighly improved the cache friendly product to use mul-add only --- Eigen/src/Core/Product.h | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 04b6fb9c0..e7ee1dc6a 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -398,15 +398,12 @@ void Product::_cacheOptimalEval(DestDerived& res, ei_meta_true const typename ei_packet_traits::type tmp3 = ei_pset1(m_lhs.coeff(k,j+3)); for (int i=0; icols(); i+=ei_packet_traits::size) { - // FIXME the following could be implemented using only mul-add, check if this is still OK for SSE res.writePacketCoeff(k,i, - ei_padd( - res.packetCoeff(k,i), - ei_padd( - ei_pmadd(tmp0, m_rhs.packetCoeff(j+0,i), ei_pmul(tmp1, m_rhs.packetCoeff(j+1,i))), - ei_pmadd(tmp2, m_rhs.packetCoeff(j+2,i), ei_pmul(tmp3, m_rhs.packetCoeff(j+3,i))) - ) - ) + ei_pmadd(tmp0, m_rhs.packetCoeff(j+0,i), + ei_pmadd(tmp1, m_rhs.packetCoeff(j+1,i), + ei_pmadd(tmp2, m_rhs.packetCoeff(j+2,i), + ei_pmadd(tmp3, m_rhs.packetCoeff(j+3,i), + res.packetCoeff(k,i))))) ); } } @@ -436,14 +433,11 @@ void Product::_cacheOptimalEval(DestDerived& res, ei_meta_true for (int i=0; irows(); i+=ei_packet_traits::size) { res.writePacketCoeff(i,k, - ei_padd( - res.packetCoeff(i,k), - ei_padd( - ei_pmadd(tmp0, m_lhs.packetCoeff(i,j), ei_pmul(tmp1, m_lhs.packetCoeff(i,j+1))), - ei_pmadd(tmp2, m_lhs.packetCoeff(i,j+2),ei_pmul(tmp3, m_lhs.packetCoeff(i,j+3))) - - ) - ) + ei_pmadd(tmp0, m_lhs.packetCoeff(i,j), + ei_pmadd(tmp1, m_lhs.packetCoeff(i,j+1), + ei_pmadd(tmp2, m_lhs.packetCoeff(i,j+2), + ei_pmadd(tmp3, m_lhs.packetCoeff(i,j+3), + res.packetCoeff(i,k))))) ); } }