From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 668D43858004; Sun, 12 Dec 2021 12:50:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 668D43858004 From: "stefan.kneifel at bluewin dot ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/103661] __builtin_cpu_supports returns a negative integer for avx512vbmi2 Date: Sun, 12 Dec 2021 12:50:53 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 11.2.1 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: stefan.kneifel at bluewin dot ch X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Dec 2021 12:50:53 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103661 --- Comment #4 from Stefan Kneifel --- Created attachment 51978 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D51978&action=3Dedit Testcase Without the proposed patch, it compiles to: -------- 0000000000000000 : 0: 50 push %rax 1: e8 00 00 00 00 call 6 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 a: R_X86_64_PC32 __cpu_model+0xa f: 5a pop %rdx 10: 0f 95 c0 setne %al 13: c3 ret=20=20=20=20 0000000000000014 : 14: 50 push %rax 15: e8 00 00 00 00 call 1a 16: R_X86_64_PLT32 __cpu_indicator_init-0x4 1a: 31 c0 xor %eax,%eax 1c: 5a pop %rdx 1d: c3 ret=20=20=20=20 -------- 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 : 0: 50 push %rax 1: e8 00 00 00 00 call 6 2: R_X86_64_PLT32 __cpu_indicator_init-0x4 6: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # c 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=20=20=20=20 0000000000000014 : 14: 50 push %rax 15: e8 00 00 00 00 call 1a 16: R_X86_64_PLT32 __cpu_indicator_init-0x4 1a: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # 20 1c: R_X86_64_PC32 __cpu_model+0x8 20: 5a pop %rdx 21: c1 e8 1f shr $0x1f,%eax 24: c3 ret=20=20=20=20 -------- returning correctly 1 if the machine has avx512vbmi2.=