[Bug target/126959] New: -march=znver4 prefers load from memory for mask register

"hjl.tools at gmail dot com via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126959

            Bug ID: 126959
           Summary: -march=znver4 prefers load from memory for mask
                    register
           Product: gcc
           Version: 16.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
  Target Milestone: ---
            Target: x86

[hjl@gnu-tgl-3 tmp]$ cat x.c
void
foo (void)
{
  unsigned short int k = 0;
  __asm volatile ("" : : "k" (k));
  k = -1;
  __asm volatile ("" : : "k" (k));
}
[hjl@gnu-tgl-3 tmp]$ gcc -S -O2 -march=tigerlake x.c
[hjl@gnu-tgl-3 tmp]$ cat x.s
        .file   "x.c"
        .text
        .p2align 4
        .globl  foo
        .type   foo, @function
foo:
.LFB0:
        .cfi_startproc
        kxorw   %k0, %k0, %k0
        kxnorw  %k1, %k1, %k1
        ret
        .cfi_endproc
.LFE0:
        .size   foo, .-foo
        .ident  "GCC: (GNU) 16.2.1 20260807 (Red Hat 16.2.1-1)"
        .section        .note.GNU-stack,"",@progbits
[hjl@gnu-tgl-3 tmp]$ gcc -S -O2 -march=znver4 x.c
[hjl@gnu-tgl-3 tmp]$ cat x.s
        .file   "x.c"
        .text
        .p2align 4
        .globl  foo
        .type   foo, @function
foo:
.LFB0:
        .cfi_startproc
        kxorw   %k0, %k0, %k0
        kmovw   .LC0(%rip), %k1
        ret
        .cfi_endproc
.LFE0:
        .size   foo, .-foo
        .section        .rodata.cst2,"aM",@progbits,2
        .align 2
.LC0:
        .value  -1
        .ident  "GCC: (GNU) 16.2.1 20260807 (Red Hat 16.2.1-1)"
        .section        .note.GNU-stack,"",@progbits
[hjl@gnu-tgl-3 tmp]$
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.