public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ondrej at sury dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/57080] New: Invalid optimization (-O2) when doing double -> int conversion (on big endian archs(?)) Date: Fri, 26 Apr 2013 10:26:00 -0000 [thread overview] Message-ID: <bug-57080-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57080 Bug #: 57080 Summary: Invalid optimization (-O2) when doing double -> int conversion (on big endian archs(?)) Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned@gcc.gnu.org ReportedBy: ondrej@sury.org Reproduceable on: Using built-in specs. COLLECT_GCC=gcc-4.6 COLLECT_LTO_WRAPPER=/usr/lib/gcc/ia64-linux-gnu/4.6/lto-wrapper Target: ia64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.3-15' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --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-gnu-unique-object --disable-libssp --enable-plugin --enable-objc-gc --with-system-libunwind --enable-checking=release --build=ia64-linux-gnu --host=ia64-linux-gnu --target=ia64-linux-gnu Thread model: posix gcc version 4.6.3 (Debian 4.6.3-15) and Using built-in specs. COLLECT_GCC=gcc-4.7 COLLECT_LTO_WRAPPER=/usr/lib/gcc/ia64-linux-gnu/4.7/lto-wrapper Target: ia64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --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.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libssp --disable-libitm --enable-plugin --enable-objc-gc --with-system-libunwind --enable-checking=release --build=ia64-linux-gnu --host=ia64-linux-gnu --target=ia64-linux-gnu Thread model: posix gcc version 4.7.2 (Debian 4.7.2-5) This bug manifest itself on ia64, powerpc and s390x (all Big Endian[1]) where gcc-4.6 is used and the optmized code (-O2) fails to produce correct math results. This code from libgd2:src/gd.c:clip_1d: *y1 -= m * (*x1 - mindim); where m = (double) -0.050000 *x1 = -200 mindim = 0 *y1 = 15 results in *y1 = 4, which is incorrect value, since it should be 5. Most simple workaround, which allows gcc to produce correct value: *y1 -= (int)(m * (*x1 - mindim)); Assigning to some other variable also works ok: int t; t = m * (*x1 - mindim); *y1 -= t; Compiling with -O0 also produces correct value. 1. Although SPARC, which should be B-E too, was built correctly.
next reply other threads:[~2013-04-26 10:26 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-04-26 10:26 ondrej at sury dot org [this message] 2013-04-26 10:27 ` [Bug c/57080] " ondrej at sury dot org 2013-04-26 11:04 ` ondrej at sury dot org 2013-04-26 12:32 ` ondrej at sury dot org 2013-04-26 16:11 ` pinskia at gcc dot gnu.org 2013-04-26 17:15 ` jakub at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-57080-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).