Re: [PATCH] x86: Allow minus ones for SSE and MASK registers

Hongtao Liu <[email protected]>
Newsgroups gmane.comp.gcc.patches
Message-ID <CAMZc-bznfaPRvcqmHptXvNfaP3U85wMuR0G9_e7cyrDb+5fTYQ@mail.gmail.com>
On Fri, Aug 21, 2026 at 9:08 AM H.J. Lu <[email protected]> wrote:
>
> Since we can load minus ones into an SSE or MASK register, allow minus
> ones for SSE and MASK registers so that
>

I think we should use standard_sse_constant_p (x, mode) for
MAYBE_SSE_CLASS_P since there's no direct instruction to move -1 to
sse register for scalar floating mode, pcmpeq is only used for vector
mode.
So how about

if (CONSTANT_P (x))
  {
    if (MAYBE_MAAX_CLASS_P (regclass))
      return NO_REGS;
    if (MAYBE_MASK_CLASS_P (regclass))
      return x == constm1_rtx ? regclass : NO_REG;
    if (MAYBE_SSE_CLASS_P (regclass))
      return (mode != VOIDmode && stardard_sse_constant_p (x, mode)) ?
regclass : NO_REGS;
}

> kxnor %k0, %k0, %k0
>
> is used to load -1 into mask register, instead of loading from memory.
>
> PR target/126959
> * config/i386/i386.cc (ix86_preferred_reload_class): Allow
> minus ones for SSE and MASK registers.
> * gcc.target/i386/pr126959-1a.c: New test.
> * gcc.target/i386/pr126959-1b.c: Likewise.
> * gcc.target/i386/pr126959-2a.c: Likewise.
> * gcc.target/i386/pr126959-2b.c: Likewise.
>
> --
> H.J.



-- 
BR,
Hongtao
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.