Re: Default value for -march option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> so I assume either your GCC was
configured for something like core-avx-i-*-* or you've found a bug.
Running 'gcc -v' will tell you what target it was configured for.

gcc -v on first machine:
=========================
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.3/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.3/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.6.3/work/gcc-4.6.3/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.3 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.3 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.3/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.3/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --without-ppl --without-cloog --enable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.6.3/python --enable-checking=release --disable-libgcj --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix
 --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.6.3 p1.8, pie-0.5.2'
Thread model: posix
gcc version 4.6.3 (Gentoo 4.6.3 p1.8, pie-0.5.2)
=========================

gcc -v on other machine, where this problem is reproduced too
=========================
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
=========================

Output from gdb:
=========================
Program received signal SIGILL, Illegal instruction.
0x00000000005e217e in __mpn_construct_double ()
(gdb) disassemble /m
Dump of assembler code for function __mpn_construct_double:
   0x00000000005e2150 <+0>:     mov    (%rdi),%rax
   0x00000000005e2153 <+3>:     add    $0x3ff,%si
   0x00000000005e2158 <+8>:     shl    $0x3f,%rdx
   0x00000000005e215c <+12>:    and    $0x7ff,%esi
   0x00000000005e2162 <+18>:    shl    $0x34,%rsi
   0x00000000005e2166 <+22>:    or     %rsi,%rdx
   0x00000000005e2169 <+25>:    movabs $0xfffff00000000,%rsi
   0x00000000005e2173 <+35>:    mov    %eax,%ecx
   0x00000000005e2175 <+37>:    and    %rsi,%rax
   0x00000000005e2178 <+40>:    or     %rcx,%rdx
   0x00000000005e217b <+43>:    or     %rax,%rdx
=> 0x00000000005e217e <+46>:    vmovq  %rdx,%xmm0
   0x00000000005e2183 <+51>:    retq   
End of assembler dump.
(gdb) bt
#0  0x00000000005e217e in __mpn_construct_double ()
#1  0x00000000005df0d0 in ____strtod_l_internal ()
#2  0x0000000000414c06 in luaO_str2d (s=0xa17b70 "1643", len=4, result=<optimized out>) at lobject.c:165
=========================

As you can see, this "vmovq" instruction appears in internal implementation of strtod() function.
Here is a piece of code from  lobject.c:165

   *result = lua_str2number(s, &endptr);

lua_str2number is defined as strtod():

    #define lua_str2number(s,p)    strtod((s), (p))



----- Original Message -----
From: Jonathan Wakely <jwakely.gcc@xxxxxxxxx>
To: Anthony S <ast_dev@xxxxxxxxx>
Cc: "gcc-help@xxxxxxxxxxx" <gcc-help@xxxxxxxxxxx>
Sent: Monday, December 17, 2012 7:06 PM
Subject: Re: Default value for -march option

On 17 December 2012 12:12, Anthony S wrote:
> What is the default value for -march option on all platforms generally and on x86_64 particularly?

There is no default in general, because it's platform-specific.

> I've compiled some code with gcc using these options:
>
> -g -O3 -fstrength-reduce -Werror -Wall -Wpointer-arith
>
>
> See that -march is not set explicitly. Code was compiled on i3 and I've found that generated executable contains AVX instructions (it failed with SIGILL in VirtualBox, VirtualBox does not support AVX yet)
>
> There is no information about default -march value in GCC docs,

There is in newer copies of the docs:
http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html

"While picking a specific cpu-type schedules things appropriately for
that particular chip, the compiler does not generate any code that
cannot run on the default machine type unless you use a
-march=cpu-type option. For example, if GCC is configured for
i686-pc-linux-gnu then -mtune=pentium4 generates code that is tuned
for Pentium 4 but still runs on i686 machines."

I didn't make that change to the GCC 4.6 docs.

> and I think that sane default value should not be -march=native or core-avx-i. Compiler should include  modern instructionsonly if it is explicitly told to do so

That's what it does.

> GCC version where this problem was found is 4.6.3

Since GCC 4.5 the default value for -march is set from the configure
target (see http://gcc.gnu.org/gcc-4.5/changes.html#x86 for the
release notes documenting the change) so I assume either your GCC was
configured for something like core-avx-i-*-* or you've found a bug.
Running 'gcc -v' will tell you what target it was configured for.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux