https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100758
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |WONTFIX
--- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> ---
(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:
> >
> > If one sets "Architecture = auto" in /etc/pacman.conf, uname only gives
> > "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.
> >
> > Details about expected features: https://archlinux32.org/architecture/
> >
> > We can add some cumbersome code which probes for sse2, but I'd really prefer
> > some compiler builtin instead :-)
>
> Eh, including cpuid.h and using that to check for SSE2 shouldn't be too hard
> (or parsing /proc/cpuinfo).
Yeah, the following should work for you:
#include <cpuid.h>
int main()
{
unsigned int eax, ebx, ecx, edx;
__get_cpuid(0, &eax, &ebx, &ecx, &edx);
if (edx & bit_SSE2)
__builtin_printf ("has SSE2\n");
}