Guard eigen_fill_helper on trivially copyable scalars
Summary
- Gate
eigen_fill_helperonstd::is_trivially_copyable<Scalar>so that non-trivially-copyable scalar types (e.g.AutoDiffScalar) fall back to Eigen's own coefficient-wise assignment loop instead ofstd::fill_n - GCC's libstdc++
fill_npessimizes non-trivially-copyable types by not hoisting the fill value out of the loop, generating extra move instructions per iteration - This is consistent with
eigen_memset_helperwhich already gates onstd::is_trivially_copyable - Trivial scalar types (
double,float,int,std::complex<double>, etc.) are unaffected and continue to use the optimizedstd::fill_npath
Test plan
- All
autodiff,autodiff_scalar,nullary,basicstuff, andzerosizedtests pass with GCC 13 - Benchmarked
setConstantonMatrix<AutoDiffScalar<Matrix<double,12,1>>, Dynamic, 1>— eliminates the regression vs pre-c01ff453 baseline
Closes #2956 (closed)