public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug ipa/60120] New: wrong code (for code with the optimize attribute) at -Os on x86_64-linux-gnu in 32-bit mode @ 2014-02-08 22:47 su at cs dot ucdavis.edu 2014-02-08 22:55 ` [Bug ipa/60120] " su at cs dot ucdavis.edu ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: su at cs dot ucdavis.edu @ 2014-02-08 22:47 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60120 Bug ID: 60120 Summary: wrong code (for code with the optimize attribute) at -Os on x86_64-linux-gnu in 32-bit mode Product: gcc Version: 4.8.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu The current gcc 4.8 branch miscompiles the following code that uses the optimize attribute on x86_64-linux at -Os in 32-bit mode (but not 64-bit). This is a regression from gcc 4.7.x and doesn't affect the current gcc trunk. $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/home/su/software/local/gcc-4.8/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.3/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-4.8/configure --enable-languages=c,c++ Thread model: posix gcc version 4.8.3 20140208 (prerelease) [gcc-4_8-branch revision 207632] (GCC) $ $ gcc -m32 -O1 small.c; a.out 2 $ gcc -m64 -Os small.c; a.out 2 $ gcc -m32 -Os small.c; a.out 1 $ $ gcc-4.7.3 -m32 -Os small.c; a.out 2 $ gcc-trunk -m32 -Os small.c; a.out 2 $ -------------------------------- int printf (const char *, ...); int a; static int fn1 (int p) { return p + 1; } static __attribute__ ((optimize (1))) int fn2 () { for (; a < 1; a = fn1 (1)) ; return 0; } __attribute__ ((optimize (0))) int fn3 () { fn1 (0); fn2 (); return 0; } int main () { fn3 (); printf ("%d\n", a); return 0; } ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug ipa/60120] wrong code (for code with the optimize attribute) at -Os on x86_64-linux-gnu in 32-bit mode 2014-02-08 22:47 [Bug ipa/60120] New: wrong code (for code with the optimize attribute) at -Os on x86_64-linux-gnu in 32-bit mode su at cs dot ucdavis.edu @ 2014-02-08 22:55 ` su at cs dot ucdavis.edu 2014-02-10 9:40 ` rguenth at gcc dot gnu.org 2014-02-10 9:42 ` rguenth at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: su at cs dot ucdavis.edu @ 2014-02-08 22:55 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60120 --- Comment #1 from Zhendong Su <su at cs dot ucdavis.edu> --- Below is another testcase that very likely points to the same root cause, so I also include it here. Hope it's useful to help diagnose the issue. $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/home/su/software/local/gcc-4.8/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.3/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-4.8/configure --enable-languages=c,c++ Thread model: posix gcc version 4.8.3 20140208 (prerelease) [gcc-4_8-branch revision 207632] (GCC) $ $ gcc -m32 -O1 small.c; a.out $ gcc -m64 -Os small.c; a.out $ $ gcc -m32 -Os small.c $ timeout -s 9 10 a.out Killed $ $ gcc-4.7.3 -m32 -Os small.c; a.out $ gcc-trunk -m32 -Os small.c; a.out $ ---------------------------- int a = 1; static int fn1 (int p1, short p2) { return p2 == 0 ? 0 : p1 / p2; } int fn2 (int p) { return 0 ? 0 : p; } __attribute__ ((optimize (0))) int fn3 () { if (fn1 (fn2 (72260), a)) ; else for (;;) ; return 0; } int main () { fn3 (); return 0; } ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug ipa/60120] wrong code (for code with the optimize attribute) at -Os on x86_64-linux-gnu in 32-bit mode 2014-02-08 22:47 [Bug ipa/60120] New: wrong code (for code with the optimize attribute) at -Os on x86_64-linux-gnu in 32-bit mode su at cs dot ucdavis.edu 2014-02-08 22:55 ` [Bug ipa/60120] " su at cs dot ucdavis.edu @ 2014-02-10 9:40 ` rguenth at gcc dot gnu.org 2014-02-10 9:42 ` rguenth at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: rguenth at gcc dot gnu.org @ 2014-02-10 9:40 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60120 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2014-02-10 Ever confirmed|0 |1 --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- This looks like a dup of PR60062 to me - we call fn1 with the argument on the stack but fn1 expects it in %eax. Fixed on trunk and thus doesn't reproduce there. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug ipa/60120] wrong code (for code with the optimize attribute) at -Os on x86_64-linux-gnu in 32-bit mode 2014-02-08 22:47 [Bug ipa/60120] New: wrong code (for code with the optimize attribute) at -Os on x86_64-linux-gnu in 32-bit mode su at cs dot ucdavis.edu 2014-02-08 22:55 ` [Bug ipa/60120] " su at cs dot ucdavis.edu 2014-02-10 9:40 ` rguenth at gcc dot gnu.org @ 2014-02-10 9:42 ` rguenth at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: rguenth at gcc dot gnu.org @ 2014-02-10 9:42 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60120 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |DUPLICATE --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- dup. *** This bug has been marked as a duplicate of bug 60062 *** ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-02-10 9:42 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-02-08 22:47 [Bug ipa/60120] New: wrong code (for code with the optimize attribute) at -Os on x86_64-linux-gnu in 32-bit mode su at cs dot ucdavis.edu 2014-02-08 22:55 ` [Bug ipa/60120] " su at cs dot ucdavis.edu 2014-02-10 9:40 ` rguenth at gcc dot gnu.org 2014-02-10 9:42 ` rguenth at gcc dot gnu.org
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).