https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103661

--- Comment #4 from Stefan Kneifel <stefan.kneifel at bluewin dot ch> ---
Created attachment 51978
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51978&action=edit
Testcase

Without the proposed patch, it compiles to:
--------
0000000000000000 <has_vbmi>:
   0:   50                      push   %rax
   1:   e8 00 00 00 00          call   6 <has_vbmi+0x6>
                        2: R_X86_64_PLT32       __cpu_indicator_init-0x4
   6:   31 c0                   xor    %eax,%eax
   8:   f6 05 00 00 00 00 04    testb  $0x4,0x0(%rip)        # f <has_vbmi+0xf>
                        a: R_X86_64_PC32        __cpu_model+0xa
   f:   5a                      pop    %rdx
  10:   0f 95 c0                setne  %al
  13:   c3                      ret    

0000000000000014 <has_vbmi2>:
  14:   50                      push   %rax
  15:   e8 00 00 00 00          call   1a <has_vbmi2+0x6>
                        16: R_X86_64_PLT32      __cpu_indicator_init-0x4
  1a:   31 c0                   xor    %eax,%eax
  1c:   5a                      pop    %rdx
  1d:   c3                      ret    
--------
returning 1 only for avx512vbmi, but not for avx512vbmi2, where it returns
always zero regardless whether the machine has it or not.


With the proposed patch, it compiles to:
--------
0000000000000000 <has_vbmi>:
   0:   50                      push   %rax
   1:   e8 00 00 00 00          call   6 <has_vbmi+0x6>
                        2: R_X86_64_PLT32       __cpu_indicator_init-0x4
   6:   8b 05 00 00 00 00       mov    0x0(%rip),%eax        # c <has_vbmi+0xc>
                        8: R_X86_64_PC32        __cpu_model+0x8
   c:   5a                      pop    %rdx
   d:   c1 e8 1a                shr    $0x1a,%eax
  10:   83 e0 01                and    $0x1,%eax
  13:   c3                      ret    

0000000000000014 <has_vbmi2>:
  14:   50                      push   %rax
  15:   e8 00 00 00 00          call   1a <has_vbmi2+0x6>
                        16: R_X86_64_PLT32      __cpu_indicator_init-0x4
  1a:   8b 05 00 00 00 00       mov    0x0(%rip),%eax        # 20
<has_vbmi2+0xc>
                        1c: R_X86_64_PC32       __cpu_model+0x8
  20:   5a                      pop    %rdx
  21:   c1 e8 1f                shr    $0x1f,%eax
  24:   c3                      ret    
--------
returning correctly 1 if the machine has avx512vbmi2.

Reply via email to