[PATCH 32/59] x86: Adapt "%v" usage on clang to emit VEX enconding

Collin Funk collin.funk1@gmail.com
Tue Nov 11 04:30:57 GMT 2025


Hi Adhemerval,

Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> writes:

> On 17/10/25 19:27, H.J. Lu wrote:
>> On Sat, Oct 18, 2025 at 3:54 AM Adhemerval Zanella
>> <adhemerval.zanella@linaro.org> wrote:
>>>
>>> clang does not support the %v to select the AVX encoding, nor the '%d' asm
>>> contrain, and for AVX build it requires all 3 arguments.
>> 
>> Does this patch change GCC codgen?
>
> It should not, gcc will still use %v as current. Only clang will
> use a different instruction selection and asm constraint:
>
> +#ifdef __clang__
> +# ifdef __AVX__
> +#  define VPREFIX    "v"
> +#  define VROUND_ARG ", %0"
> +# else
> +#  define VPREFIX    ""
> +#  define VROUND_ARG ""
> +# endif
> +# define VARGPREFIX  "%"
> +#else
> +# define VPREFIX     "%v"
> +# define VARGPREFIX  "%d"
> +# define VROUND_ARG  ""
> +#endif

I bisected 65 test failures to this commit. On a x86_64 Fedora 43 system
with the following gcc:

    $ gcc --version | head -n 1
    gcc (GCC) 15.2.1 20251022 (Red Hat 15.2.1-3)

The main ones are:

    FAIL: math/test-fenv
    FAIL: math/test-fenv-clear
    FAIL: math/test-fenv-clear-sse
    FAIL: math/test-fenv-return
    FAIL: math/test-fenv-x87

The others are likely just a result of the exception mask and/or
rounding mode not being set correctly.

I am a bit surprised since the patch looks okay upon my quick skim over
it, just moving some inline asm statements into inline functions.

Let me know if you want me to file a bug report.

Collin


More information about the Libc-alpha mailing list