rogerdpack
rogerdpack

Reputation: 66861

which cpu is targeted with gcc's -mtune=generic?

With gcc, you can specify "-mtune=" or "-mtune=generic"

How can I know which architecture is targeted with "-mtune=generic" for gcc? It's supposed to be varying based on different versions of GCC?

The docs https://gcc.gnu.org/onlinedocs/gcc-5.4.0/gcc/x86-Options.html#x86-Options say:

As new processors are deployed in the marketplace, the behavior of this option will change. Therefore, if you upgrade to a newer version of GCC, code generation controlled by this option will change to reflect the processors that are most common at the time that version of GCC is released.

How can I know which one each version of GCC targets?

The docs say:

https://gcc.gnu.org/onlinedocs/gcc-5.4.0/gcc/x86-Options.html#x86-Options

...
‘i686’
When used with -march, the Pentium Pro instruction set is used, 
so the code runs on all i686 family chips. When used with -mtune, it has the same meaning as ‘generic’. 

So I guess generic "means" i686 but is that a particular CPU?

Upvotes: 3

Views: 3945

Answers (1)

osgx
osgx

Reputation: 94415

How can I know which architecture is targeted with "-mtune=generic" for gcc?

By reading the true documentation, the source code of gcc (search for PROCESSOR_GENERIC after switch(tune):

For x86 (32/64 bit) gcc/config/i386/i386-c.c it will not define builtins/arch macro,

  /* Built-ins based on -mtune=.  */
  switch (tune)

    case PROCESSOR_GENERIC:
      break;

and gcc/config/i386/driver-i386.c will not detect local cpu with cpuid (host_detect_local_cpu will not be called without cpu=native / tune=native

You may try adding -fverbose-asm -S and check first lines of generated asm for options..

Upvotes: 1

Related Questions