This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/70251] New: Wrong code with -O3 -march=skylake-avx512.
- From: "vsevolod.livinskij at frtk dot ru" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 16 Mar 2016 06:35:44 +0000
- Subject: [Bug c++/70251] New: Wrong code with -O3 -march=skylake-avx512.
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70251
Bug ID: 70251
Summary: Wrong code with -O3 -march=skylake-avx512.
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: vsevolod.livinskij at frtk dot ru
Target Milestone: ---
Created attachment 37985
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37985&action=edit
Reproducer.
Test case produces incorrect result with -O3 -march=skylake-avx512. It gives
different result for every launch. Everything works fine with -O2 option.
Output:
> g++ repr.cpp -o out -O3 -march=skylake-avx512; sde -skx -- ./out
12033857864019976279
> g++ repr.cpp -o out -O2 -march=skylake-avx512; sde -skx -- ./out
5785906989299578598
GCC version:
> g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/export/users/vlivinsk/gcc-trunk/bin/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /export/users/vlivinsk/gcc-trunk/gcc/configure
--with-arch=corei7 --with-cpu=corei7 --enable-clocale=gnu --with-system-zlib
--enable-shared --with-demangler-in-ld --enable-cloog-backend=isl
--with-fpmath=sse --enable-checking=release --enable-languages=c,c++,lto
--with-gmp=/export/users/vlivinsk/gcc-trunk/gmp-6.1.0/bin
--with-mpfr=/export/users/vlivinsk/gcc-trunk/mpfr-3.1.3/bin
--with-mpc=/export/users/vlivinsk/gcc-trunk/mpc-1.0.3/bin
--prefix=/export/users/vlivinsk/gcc-trunk/bin
Thread model: posix
gcc version 6.0.0 20160315 (experimental) (Revision=234226)
Test:
#include <iostream>
void hash(unsigned long long int &seed, unsigned long long int const &v) {
seed ^= v + 0x9e3779b9 + (seed<<6) + (seed>>2);
}
unsigned int a [100];
signed char b [100];
signed char c [100];
void init () {
for (int i = 0; i < 100; ++i) {
a [i] = 1000L;
b [i] = 10;
c [i] = 5;
}
}
void foo () {
for (int i = 0; i < 100; ++i)
b [i] = (!b [i] ^ (a [i] >= b [i])) + c [i];
}
unsigned long long int checksum () {
unsigned long long int seed = 0ULL;
for (int i = 0; i < 100; ++i)
hash(seed, b [i]);
return seed;
}
int main () {
init ();
foo ();
std::cout << checksum () << std::endl;
return 0;
}