This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Choosing the right -march target architecture


On 3 September 2015 at 09:45, Mason wrote:
> I noticed something strange in gcc -v output:
>
> $ gcc -v -c foo.c
> ...
> gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
> COLLECT_GCC_OPTIONS='-v' '-c' '-mtune=generic' '-march=x86-64'
>  /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1 -quiet -v -imultiarch x86_64-linux-gnu foo.c -quiet -dumpbase foo.c -mtune=generic -march=x86-64 -auxbase foo -version -fstack-protector -Wformat -Wformat-security -o /tmp/ccFwNaX5.s
>
>
> -mtune=generic -march=x86-64
> Won't the -march option override the -mtune option?

No, I don't think so.

I assume the explicit -mtune overrides the implicit one.

> Another thing. I was under the impression that when the target
> platform is x86_64 (so not the same x86-64 as above) then some

x86-64 is the argument to -march and -mtune that means "the generic
x86_64 instruction set" so when the target platform is x86_64 and
there is no (implicit or explicit) -march then the instruction set
used is as if -march=x86-64 was specified.

> options are enabled by default, such as -msse and -msse2.
> Is that correct?

Yes. You can easily check by using -S -fverbose-asm and looking at the
assembly output, which will list the active options.

> Or is just the use of SSE for FP? i.e. -mfpmath=sse
> "For the i386 compiler, you must use -march=cpu-type, -msse or -msse2
> switches to enable SSE extensions and make this option effective.
> For the x86-64 compiler, these extensions are enabled by default."
>
>
> gcc -v does not print what instruction-set extensions it will
> be using? Is there a way to know that gcc used e.g. SSE3
> instructions in the code generation?

-fverbose-asm


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]