[Mesa-dev] [PATCH] util: Prefer atomic intrinsics to inline assembly.

Matt Turner mattst88 at gmail.com
Fri Nov 21 15:30:07 PST 2014


On Fri, Nov 21, 2014 at 3:18 PM, Matt Turner <mattst88 at gmail.com> wrote:
> Cuts a little more than 1k of .text size from i915g.
>
> This was previously done in commit 5f66b340 and subsequently reverted in
> commit 3661f757 after bug 30514 was filed. I believe the cause of bug
> 30514 wasn't anything related to cross compiling, but rather that the
> toolchain used defaulted to -march=i386, and i386 doesn't have the
> CMPXCHG or XADD instructions used to implement the intrinsics.
>
> So we reverted a patch that improved things so that we didn't break
> compilation for a platform that never could have worked anyway.
> ---
> I wouldn't mind some kind of check that this hardware support is available
> but I don't know how to do it. gcc -m32 defines __i386__, which doesn't
> tell you that you're compiling with -march=i386, but rather that you're
> compiling with -m32. Using -march=i486 defines both __i386__ and __i486__.
>
>  src/gallium/auxiliary/util/u_atomic.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/auxiliary/util/u_atomic.h b/src/gallium/auxiliary/util/u_atomic.h
> index 9731aa0..b01aa38 100644
> --- a/src/gallium/auxiliary/util/u_atomic.h
> +++ b/src/gallium/auxiliary/util/u_atomic.h
> @@ -23,13 +23,13 @@
>  #elif defined(PIPE_CC_MSVC)
>  #define PIPE_ATOMIC_MSVC_INTRINSIC
>  #elif (defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86))
> +#elif defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 401)
> +#define PIPE_ATOMIC_GCC_INTRINSIC

Sending patches too quickly... these two lines obviously need to be
moved after the following one.

>  #define PIPE_ATOMIC_ASM_MSVC_X86


More information about the mesa-dev mailing list