From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ED290384F004; Wed, 26 May 2021 10:09:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED290384F004 From: "marxin at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/100758] __builtin_cpu_supports does not (always) detect "sse2" Date: Wed, 26 May 2021 10:09:17 +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.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: marxin at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: WONTFIX X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: marxin at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status resolution 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: Wed, 26 May 2021 10:09:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100758 Martin Li=C5=A1ka changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |WONTFIX --- Comment #6 from Martin Li=C5=A1ka --- (In reply to Richard Biener from comment #5) > (In reply to Erich Eckner from comment #2) > > We use this in archlinux32 to detect, if we can install packages, that = have > > sse2 opcodes: > >=20 > > If one sets "Architecture =3D auto" in /etc/pacman.conf, uname only giv= es > > "i686" in both cases (this is how archlinux does/did the probing), and = then, > > we probe for sse2 to check, if we really are "i686" or "pentium4" (our > > nomenclature for "i686" + sse2). This works well on amd and intel cpus,= but > > fails on via cpus. > >=20 > > Details about expected features: https://archlinux32.org/architecture/ > >=20 > > We can add some cumbersome code which probes for sse2, but I'd really p= refer > > some compiler builtin instead :-) >=20 > Eh, including cpuid.h and using that to check for SSE2 shouldn't be too h= ard > (or parsing /proc/cpuinfo). Yeah, the following should work for you: #include int main() { unsigned int eax, ebx, ecx, edx; __get_cpuid(0, &eax, &ebx, &ecx, &edx); if (edx & bit_SSE2) __builtin_printf ("has SSE2\n"); }=