On Wed, Sep 25, 2024 at 2:56 PM Jan Beulich <jbeul...@suse.com> wrote:
>
> Commit a79d13a01f8c ("i386: Fix aes/vaes patterns [PR114576]") correctly
> said "..., but we need to emit {evex} prefix in the assembly if AES ISA
> is not enabled". Yet it did so only for the TARGET_AES insns. Going from
> the alternative chosen in the TARGET_VAES insns is wrong for two
> reasons:
> - if, with AES disabled, the latter alternative was chosen despite no
>   "high" XMM register nor any eGPR in use, gas would still pick the AES
w/o EVEX SSE REG or EGPR, the first alternative will always be
matched(alternative 0).
That is how it works(match from left to right).
>   (VEX) encoding when no {evex} pseudo-prefix is in use (which is
>   against - as stated by the description of said commit - AES presently
>   not being considered a prereq of VAES in gcc);

> - if AES is (also) enabled, EVEX encoding would needlessly be forced.
So it's more like an optimization that use VEX encoding when AES is enabled?
>
> gcc/
>
>         * config/i386/sse.md (vaesdec_<mode>, vaesdeclast_<mode>,
>         vaesenc_<mode>, vaesenclast_<mode>): Replace which_alternative
>         check by TARGET_AES one.
> ---
> As an aside - {evex} (and other) pseudo-prefixes would better be avoided
> anyway whenever possible, as those are getting in the way of code
> putting in place macro overrides for certain insns: gas 2.43 rejects
> such bogus placement of pseudo-prefixes.
>
> --- a/gcc/config/i386/sse.md
> +++ b/gcc/config/i386/sse.md
> @@ -30802,7 +30802,7 @@
>           UNSPEC_VAESDEC))]
>    "TARGET_VAES"
>  {
> -  if (which_alternative == 0 && <MODE>mode == V16QImode)
> +  if (!TARGET_AES && <MODE>mode == V16QImode)
>      return "%{evex%} vaesdec\t{%2, %1, %0|%0, %1, %2}";
>    else
>      return "vaesdec\t{%2, %1, %0|%0, %1, %2}";
> @@ -30816,7 +30816,7 @@
>           UNSPEC_VAESDECLAST))]
>    "TARGET_VAES"
>  {
> -  if (which_alternative == 0 && <MODE>mode == V16QImode)
> +  if (!TARGET_AES && <MODE>mode == V16QImode)

>      return "%{evex%} vaesdeclast\t{%2, %1, %0|%0, %1, %2}";
>    else
>      return "vaesdeclast\t{%2, %1, %0|%0, %1, %2}";
> @@ -30830,7 +30830,7 @@
>           UNSPEC_VAESENC))]
>    "TARGET_VAES"
>  {
> -  if (which_alternative == 0 && <MODE>mode == V16QImode)
> +  if (!TARGET_AES && <MODE>mode == V16QImode)
>      return "%{evex%} vaesenc\t{%2, %1, %0|%0, %1, %2}";
>    else
>      return "vaesenc\t{%2, %1, %0|%0, %1, %2}";
> @@ -30844,7 +30844,7 @@
>           UNSPEC_VAESENCLAST))]
>    "TARGET_VAES"
>  {
> -  if (which_alternative == 0 && <MODE>mode == V16QImode)
> +  if (!TARGET_AES && <MODE>mode == V16QImode)
>      return "%{evex%} vaesenclast\t{%2, %1, %0|%0, %1, %2}";
>    else
>      return "vaesenclast\t{%2, %1, %0|%0, %1, %2}";



-- 
BR,
Hongtao

Reply via email to