CPUTYPE=native handling

Dimitry Andric dim at FreeBSD.org
Tue Nov 8 22:06:11 UTC 2011


On 2011-11-08 22:04, Alexander Best wrote:
...
> for me -march=native reports:
> 
> otaku% gcc -march=native -E -v - </dev/null
> Using built-in specs.
> Target: amd64-undermydesk-freebsd
> Configured with: FreeBSD/amd64 system compiler
> Thread model: posix
> gcc version 4.2.2 20070831 prerelease [FreeBSD]
>  /usr/libexec/cc1 -E -quiet -v -D_LONGLONG - -march=nocona -mtune=generic
> #include "..." search starts here:
> #include <...> search starts here:
>  /usr/include/gcc/4.2
>  /usr/include
> End of search list.
> # 1 "<stdin>"
> # 1 "<built-in>"
> # 1 "<command-line>"
> # 1 "<stdin>"
> 
> where instead of nocona, core2 would have been the better choice:
> 
> [1.000000] CPU: Intel(R) Pentium(R) Dual  CPU  E2160  @ 1.80GHz (1800.00-MHz K8-class CPU)
> [1.000000]   Origin = "GenuineIntel"  Id = 0x6fd  Family = 6  Model = f  Stepping = 13
> [1.000000]   Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
> [1.000000]   Features2=0xe39d<SSE3,DTES64,MON,DS_CPL,EST,TM2,SSSE3,CX16,xTPR,PDCM>
> [1.000000]   AMD Features=0x20100800<SYSCALL,NX,LM>
> [1.000000]   AMD Features2=0x1<LAHF>
> [1.000000]   TSC: P-state invariant, performance statistics

That's weird, the logic in gcc goes:

  cpuid (1, eax, ebx, ecx, edx);
...
  has_ssse3 = !!(ecx & bit_SSSE3);
...
          if (arch)
            {
              if (has_ssse3)
                cpu = "core2";
              else if (has_sse3)
                {
                  if (has_longmode)
                    cpu = "nocona";
                  else
                    cpu = "prescott";
                }
              else if (has_sse2)
                cpu = "pentium4";
              else if (has_cmov)
                cpu = "pentiumpro";
              else if (has_mmx)
                cpu = "pentium-mmx";
              else if (has_cmpxchg8b)
                cpu = "pentium";
              else
                cpu = "i386";
            }
          else
            cpu = "generic";
          goto done;

E.g. it seems to conclude your cpu *doesn't* have SSSE3, but does have
long mode, and thus jumps to nocona.

You might be able to debug this, by putting some printfs in this
function. :)


More information about the freebsd-toolchain mailing list