From 42c62c8876283b24aee574584844526480bd8fa4 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Wed, 16 Jun 2010 09:23:32 -0400 Subject: [PATCH] fix #126, part 2/2: the checkTransposeAliasing() assertion was always compiled, for all expressions, even for expressions that are known at compile time to not need it because they don't involve any transposing. This gave 'controlling condition is constant' warnings on ICC, and potentially worse, this could generate a lot of useless code per-expression if the compiler failed to realize that the condition was constant. --- Eigen/src/Core/Transpose.h | 55 +++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index 6928ae31a..b1a509a3e 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -310,8 +310,23 @@ struct ei_blas_traits > static inline const XprType extract(const XprType& x) { return x; } }; +template +struct ei_check_transpose_aliasing_compile_time_selector +{ + enum { ret = ei_blas_traits::IsTransposed != DestIsTranposed + }; +}; + +template +struct ei_check_transpose_aliasing_compile_time_selector > +{ + enum { ret = ei_blas_traits::IsTransposed != DestIsTranposed + || ei_blas_traits::IsTransposed != DestIsTranposed + }; +}; + template -struct ei_check_transpose_aliasing_selector +struct ei_check_transpose_aliasing_run_time_selector { static bool run(const Scalar* dest, const OtherDerived& src) { @@ -320,7 +335,7 @@ struct ei_check_transpose_aliasing_selector }; template -struct ei_check_transpose_aliasing_selector > +struct ei_check_transpose_aliasing_run_time_selector > { static bool run(const Scalar* dest, const CwiseBinaryOp& src) { @@ -329,12 +344,44 @@ struct ei_check_transpose_aliasing_selector::IsTransposed,OtherDerived>::ret + > +struct checkTransposeAliasing_impl +{ + static void run(const Derived& dst, const OtherDerived& other) + { + ei_assert((!ei_check_transpose_aliasing_run_time_selector + ::IsTransposed,OtherDerived> + ::run(ei_extract_data(dst), other)) + && "aliasing detected during tranposition, use transposeInPlace() " + "or evaluate the rhs into a temporary using .eval()"); + + } +}; + +template +struct checkTransposeAliasing_impl +{ + static void run(const Derived&, const OtherDerived&) + { + } +}; + + template template void DenseBase::checkTransposeAliasing(const OtherDerived& other) const { - ei_assert((!ei_check_transpose_aliasing_selector::IsTransposed,OtherDerived>::run(ei_extract_data(derived()), other)) - && "aliasing detected during tranposition, use transposeInPlace() or evaluate the rhs into a temporary using .eval()"); + checkTransposeAliasing_impl::run(derived(), other); } #endif