From be76d96e8f725aa8041af978572c24543171e077 Mon Sep 17 00:00:00 2001 From: myfreeer Date: Sun, 19 Mar 2023 11:56:59 +0800 Subject: [PATCH] simd128: inline _mm_set_ps --- include/cglm/simd/wasm.h | 6 ------ include/cglm/simd/wasm/affine.h | 3 +-- include/cglm/simd/wasm/mat4.h | 6 +++--- include/cglm/simd/wasm/quat.h | 2 +- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/include/cglm/simd/wasm.h b/include/cglm/simd/wasm.h index 9c7787f..a279df1 100644 --- a/include/cglm/simd/wasm.h +++ b/include/cglm/simd/wasm.h @@ -55,12 +55,6 @@ _mm_movelh_ps(glmm_128 __a, glmm_128 __b) return wasm_i32x4_shuffle(__a, __b, 0, 1, 4, 5); } -static __inline__ glmm_128 __attribute__((__always_inline__, __nodebug__)) -_mm_set_ps(float __z, float __y, float __x, float __w) -{ - return (glmm_128)wasm_f32x4_make(__w, __x, __y, __z); -} - static inline glmm_128 __attribute__((__always_inline__, __nodebug__)) _mm_sqrt_ss(glmm_128 __a) { diff --git a/include/cglm/simd/wasm/affine.h b/include/cglm/simd/wasm/affine.h index b0919f5..cbf8ce4 100644 --- a/include/cglm/simd/wasm/affine.h +++ b/include/cglm/simd/wasm/affine.h @@ -91,8 +91,7 @@ glm_inv_tr_wasm(mat4 mat) { r1 = glmm_load(mat[1]); r2 = glmm_load(mat[2]); r3 = glmm_load(mat[3]); - x1 = _mm_set_ps(1.0f, 0.0f, 0.0f, 0.0f); - + x1 = wasm_f32x4_const(0.0f, 0.0f, 0.0f, 1.0f); _MM_TRANSPOSE4_PS(r0, r1, r2, x1); x2 = glmm_shuff1(r3, 0, 0, 0, 0); diff --git a/include/cglm/simd/wasm/mat4.h b/include/cglm/simd/wasm/mat4.h index a1d13ea..aa696b1 100644 --- a/include/cglm/simd/wasm/mat4.h +++ b/include/cglm/simd/wasm/mat4.h @@ -153,7 +153,7 @@ glm_mat4_det_wasm(mat4 mat) { _mm_shuffle_ps(x0, x1, _MM_SHUFFLE(2, 2, 3, 1)), x2); - x2 = wasm_v128_xor(x2, _mm_set_ps(-0.f, 0.f, -0.f, 0.f)); + x2 = wasm_v128_xor(x2, wasm_f32x4_const(0.f, -0.f, 0.f, -0.f)); return glmm_hadd(wasm_f32x4_mul(x2, r0)); } @@ -166,7 +166,7 @@ glm_mat4_inv_fast_wasm(mat4 mat, mat4 dest) { t0, t1, t2, t3, t4, t5, x0, x1, x2, x3, x4, x5, x6, x7, x8, x9; - x8 = wasm_f32x4_make(-0.f, 0.f, -0.f, 0.f); + x8 = wasm_f32x4_const(-0.f, 0.f, -0.f, 0.f); x9 = glmm_shuff1(x8, 2, 1, 2, 1); /* 127 <- 0 */ @@ -302,7 +302,7 @@ glm_mat4_inv_wasm(mat4 mat, mat4 dest) { t0, t1, t2, t3, t4, t5, x0, x1, x2, x3, x4, x5, x6, x7, x8, x9; - x8 = _mm_set_ps(-0.f, 0.f, -0.f, 0.f); + x8 = wasm_f32x4_const(0.f, -0.f, 0.f, -0.f); x9 = glmm_shuff1(x8, 2, 1, 2, 1); /* 127 <- 0 */ diff --git a/include/cglm/simd/wasm/quat.h b/include/cglm/simd/wasm/quat.h index 8367214..ccbcec2 100644 --- a/include/cglm/simd/wasm/quat.h +++ b/include/cglm/simd/wasm/quat.h @@ -26,7 +26,7 @@ glm_quat_mul_wasm(versor p, versor q, versor dest) { xp = glmm_load(p); /* 3 2 1 0 */ xq = glmm_load(q); - x1 = _mm_set_ps(-0.f, 0.f, -0.f, 0.f); /* TODO: _mm_set1_ss() + shuff ? */ + x1 = wasm_f32x4_const(0.f, -0.f, 0.f, -0.f); /* TODO: _mm_set1_ss() + shuff ? */ r = wasm_f32x4_mul(glmm_splat_w(xp), xq); x2 = _mm_unpackhi_ps(x1, x1);