This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/72824] New: [7 Regression] Signed floating point zero semantics broken at optimization level -O3 (tree-loop-distribute-patterns)
- From: "wenzel at mitsuba-renderer dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 06 Aug 2016 12:15:07 +0000
- Subject: [Bug tree-optimization/72824] New: [7 Regression] Signed floating point zero semantics broken at optimization level -O3 (tree-loop-distribute-patterns)
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72824
Bug ID: 72824
Summary: [7 Regression] Signed floating point zero semantics
broken at optimization level -O3
(tree-loop-distribute-patterns)
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: wenzel@mitsuba-renderer.org
Target Milestone: ---
The trunk version of GCC has a regression which optimizes away signed zeros at
optimization level -O3. This should never happen unless more aggressive
optimization flags are specified (like -ffast-math or -fno-signed-zeros,
neither of which are part of -O3). Having correct signed zero semantics is
important for many scientific computing applications.
$ g++-7 test.cpp -o test -O2
$ ./test
-0.000000 # <---- Correct
$ g++-7 test.cpp -o test -O3
$ ./test
0.000000 # <---- Signed zero gone
It's possible to fix the issue by adding -fno-tree-loop-distribute-patterns, so
I assume that it is somehow related to this optimization.
Program to reproduce:
#include <stdio.h>
template <size_t Size>
struct Array {
Array(float value) {
for (size_t i = 0; i<Size; ++i)
x[i] = value;
}
float x[Size];
};
int main(int argc, char *argv[]) {
Array<8> array(-0.f);
printf("%f\n", array.x[0]);
return 0;
}
This is with the latest trunk version of GCC:
$ g++-7 -v
Using built-in specs.
COLLECT_GCC=g++-7
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/HEAD-/libexec/gcc/x86_64-apple-darwin15.6.0/7.0.0/lto-wrapper
Target: x86_64-apple-darwin15.6.0
Configured with: ../configure --build=x86_64-apple-darwin15.6.0
--prefix=/usr/local/Cellar/gcc/HEAD-
--libdir=/usr/local/Cellar/gcc/HEAD-/lib/gcc/
--enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-
--with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr
--with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl
--with-system-zlib --enable-libstdcxx-time=yes --enable-stage1-checking
--enable-checking=release --enable-lto --with-build-config=bootstrap-debug
--disable-werror --with-pkgversion='Homebrew gcc HEAD- --without-multilib'
--with-bugurl=https://github.com/Homebrew/homebrew/issues --enable-plugin
--disable-nls --disable-multilib
Thread model: posix
gcc version 7.0.0 20160804 (experimental) (Homebrew gcc HEAD-
--without-multilib)