[Bug middle-end/32820] optimizer malfunction when mixed with asm statements
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32820 --- Comment #8 from Siarhei Siamashka 2010-10-25 10:17:47 UTC --- On the second thought, this bug was about global variables. But my problem is related to the use of local variables. So I have submitted a separate PR46164 about it.
[Bug middle-end/32820] optimizer malfunction when mixed with asm statements
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32820 Siarhei Siamashka changed: What|Removed |Added CC||siarhei.siamashka at gmail ||dot com --- Comment #7 from Siarhei Siamashka 2010-10-11 19:18:46 UTC --- Looks like this or similar "Variables in Specified Registers" bug is also reproducible on ARM with gcc 4.5.1 $ cat test.c int f(int a) { register int result asm("r0"); asm ( "addr0, %[a], #123\n" : [result] "=&r" (result) : [a] "r" (a) ); return result; } $ gcc -O2 -c test.c $ objdump -d test.o : 0: e280007badd r0, r0, #123; 0x7b 4: e1a3mov r0, r3 8: e12fff1ebx lr Here the local variable 'result' gets assigned to register r3 instead of r0 causing all kind of problems.
[Bug middle-end/32820] optimizer malfunction when mixed with asm statements
--- Comment #6 from danglin at gcc dot gnu dot org 2009-02-04 04:24 --- I tried the testcase with 4.4.0. The problem is not fixed. All the explicit register variables are optimized away at -O. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32820
[Bug middle-end/32820] optimizer malfunction when mixed with asm statements
--- Comment #5 from steven at gcc dot gnu dot org 2007-11-26 14:10 --- Thanks for the effort you have put into this. Your bug is probably fixed in GCC 4.3 (for which the entire dataflow module has been rewritten from scratch) but it probably still exists in GCC 4.2. As you have shown, the bug exists since GCC 3.0, so the bug is not a regression. GCC 4.2 and earlier are in "regression fixes only" mode. This means, I'm sorry to say, that your bug will not be fixed for these already released GCC versions. Could you please test this bug with a recent GCC 4.3 snapshot? If the bug persists, we can still fix the problem before GCC 4.3 is released. -- steven at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |WAITING http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32820
[Bug middle-end/32820] optimizer malfunction when mixed with asm statements
--- Comment #4 from jbuehler at spirentcom dot com 2007-08-09 11:38 --- Created an attachment (id=14045) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14045&action=view) gcc 4.0.4 global register variable optimizer patch The attached patch fixes the optimizer bug for gcc 4.0.4 and allows GHC 6.6.1 to be compiled with optimization turned on. The problem is that lifetime analysis is marking global registers as REG_UNUSED and then the combiner pass is eliminating them. The fix is to not mark global registers as unused. The fix is based on a review of the flow.c code for gcc 4.2.0. Code was added to flow.c somewhere after 4.0.4 to handle "stack registers" and no mark them as REG_UNUSED. This patch merely mimics "stack register" handling in flow.c for global registers. I am not a gcc expert and make no claims for the correctness of this patch -- it does fix my ghc compile though. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32820
[Bug middle-end/32820] optimizer malfunction when mixed with asm statements
--- Comment #3 from jbuehler at spirentcom dot com 2007-07-25 13:28 --- I would appreciate a fix for this because the code being compiled is the GHC compiler itself. I have to compile GHC for hppa without optimization because I have been unable to find a compiler options workaround for this problem. The unoptimized GHC has a 40 megabyte text section and I am hoping for significant speed improvements once the optimizer is usable. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32820
[Bug middle-end/32820] optimizer malfunction when mixed with asm statements
--- Comment #2 from jbuehler at spirentcom dot com 2007-07-25 13:22 --- The same bug is present in the following versions of gcc for sparc-sun-solaris2.9: 2.95.3 2.95 3.0.2 3.0.4 3.1.1 3.2.3 3.3.6 3.4.6 4.0.1 4.0.4 4.1.2 4.2.0 Use registers l1, l2, l3, l4 in the sample code to demonstrate the problem. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32820
[Bug middle-end/32820] optimizer malfunction when mixed with asm statements
--- Comment #1 from jbuehler at spirentcom dot com 2007-07-25 13:09 --- This bug is also present in 4.0.1 for powerpc-ibm-aix5.2.0.0. Change the registers in the problematic code to r14, r15, r16, r17 -- one of the registers is not set by the optimized routine, but is by the non-optimized routine. I presume that this is not a target-specific bug. -- jbuehler at spirentcom dot com changed: What|Removed |Added CC||jbuehler at spirentcom dot ||com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32820