sse: optimize glm_mat2_mul_sse2 with sse
CGLM_INLINE
void
glm_mat2_mul_sse2(mat2 m1, mat2 m2, mat2 dest) {
- __m128 x0, x1, x2;
+ __m128 x0, x1, x2, x3, x4;
x1 = glmm_load(m1[0]); /* d c b a */
x2 = glmm_load(m2[0]); /* h g f e */
+ x3 = glmm_shuff1(x2, 2, 2, 0, 0);
+ x4 = glmm_shuff1(x2, 3, 3, 1, 1);
+ x0 = _mm_movelh_ps(x1, x1);
+ x2 = _mm_movehl_ps(x1, x1);
+
/*
dest[0][0] = a * e + c * f;
dest[0][1] = b * e + d * f;
dest[1][0] = a * g + c * h;
dest[1][1] = b * g + d * h;
*/
- x0 = glmm_fmadd(_mm_movelh_ps(x1, x1), glmm_shuff1(x2, 2, 2, 0, 0),
- _mm_mul_ps(_mm_movehl_ps(x1, x1),
- glmm_shuff1(x2, 3, 3, 1, 1)));
+ x0 = glmm_fmadd(x0, x3, _mm_mul_ps(x2, x4));
glmm_store(dest[0], x0);
}
