From 30064a19770809fbb25f5f19a11389812c7f22a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20P=2E=20Tjern=C3=B8?= Date: Tue, 3 Dec 2013 10:34:47 -0800 Subject: [PATCH] Specify clobbered registers in POSIX SSE functions We weren't specifying clobbered registers for our SSE implementations of VectorNormalize and InvRSquared. Supposedly GCC and clang does not inspect the assembly to figure out which registers are getting clobbered, so this could potentially fix some bugs. This fixes GH-195. --- sp/src/mathlib/sse.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sp/src/mathlib/sse.cpp b/sp/src/mathlib/sse.cpp index a2445c79..2260550b 100644 --- a/sp/src/mathlib/sse.cpp +++ b/sp/src/mathlib/sse.cpp @@ -259,6 +259,7 @@ float FASTCALL _SSE_VectorNormalize (Vector& vec) "movaps %%xmm4, %1 \n\t" : "=m" (radius), "=m" (result) : "m" (*v) + : "xmm1", "xmm2", "xmm3", "xmm4" ); #else #error "Not Implemented" @@ -322,8 +323,9 @@ float _SSE_InvRSquared(const float* v) "maxss %%xmm5, %%xmm1 \n\t" "rcpss %%xmm1, %%xmm0 \n\t" "movss %%xmm0, %0 \n\t" - : "=m" (inv_r2) - : "m" (*v), "0" (inv_r2) + : "+m" (inv_r2) + : "m" (*v) + : "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" ); #else #error "Not Implemented"