1 /*
2  * Copyright (c), Recep Aslantas.
3  *
4  * MIT License (MIT), http://opensource.org/licenses/MIT
5  * Full license can be found in the LICENSE file
6  */
7 
8 #ifndef cglm_mat2_neon_h
9 #define cglm_mat2_neon_h
10 #if defined(__ARM_NEON_FP)
11 
12 #include "../../common.h"
13 #include "../intrin.h"
14 
15 CGLM_INLINE
16 void
glm_mat2_mul_neon(mat2 m1,mat2 m2,mat2 dest)17 glm_mat2_mul_neon(mat2 m1, mat2 m2, mat2 dest) {
18   float32x4x2_t a1;
19   glmm_128 x0,  x1, x2;
20   float32x2_t   dc, ba;
21 
22   x1 = glmm_load(m1[0]); /* d c b a */
23   x2 = glmm_load(m2[0]); /* h g f e */
24 
25   dc = vget_high_f32(x1);
26   ba = vget_low_f32(x1);
27 
28   /* g g e e, h h f f */
29   a1 = vtrnq_f32(x2, x2);
30 
31   /*
32    dest[0][0] = a * e + c * f;
33    dest[0][1] = b * e + d * f;
34    dest[1][0] = a * g + c * h;
35    dest[1][1] = b * g + d * h;
36    */
37   x0 = glmm_fmadd(vcombine_f32(ba, ba), a1.val[0],
38                   vmulq_f32(vcombine_f32(dc, dc), a1.val[1]));
39 
40   glmm_store(dest[0], x0);
41 }
42 
43 #endif
44 #endif /* cglm_mat2_neon_h */
45