Set cost of constant expression to 0 (the cost should be amortized through the expression)

This commit is contained in:
Gael Guennebaud 2016-06-14 11:29:06 +02:00
parent deb8306e60
commit f5b1c73945

View File

@ -26,7 +26,8 @@ struct scalar_constant_op {
}; };
template<typename Scalar> template<typename Scalar>
struct functor_traits<scalar_constant_op<Scalar> > struct functor_traits<scalar_constant_op<Scalar> >
{ enum { Cost = 1, PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = true }; }; { enum { Cost = 0 /* as the constant value should be loaded in register only once for the whole expression */,
PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = true }; };
template<typename Scalar> struct scalar_identity_op { template<typename Scalar> struct scalar_identity_op {
EIGEN_EMPTY_STRUCT_CTOR(scalar_identity_op) EIGEN_EMPTY_STRUCT_CTOR(scalar_identity_op)