Currently expressions like void foo(Array2d &a, const double s) { a = s - a; } lead to this inefficient code (only excerpt shown, comments added): movapd .LC0, %xmm0 #.LC0 is a {-0.0, -0.0} xorpd (%eax), %xmm0 # negate elements of a movddup 8(%esp), %xmm1 # load s addpd %xmm1, %xmm0 # add s + (-a) movapd %xmm0, (%eax) # store result This could be implemented more efficiently using the subpd instruction: movddup 8(%esp), %xmm0 # load s subpd (eax), %xmm0 # subtract s - a movapd %xmm0, (%eax) # store result
I hoped the compiler would optimize this by itself, but that's not the case. Here is the fix: https://bitbucket.org/eigen/eigen/commits/0720fd0684a9/ Changeset: 0720fd0684a9 User: ggael Date: 2013-10-18 14:56:36 Summary: Fix bug 684: optimize vectorization of array-scalar and scalar-array
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/684.