public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/32820] optimizer malfunction when mixed with asm statements
       [not found] <bug-32820-4@http.gcc.gnu.org/bugzilla/>
@ 2010-10-11 19:18 ` siarhei.siamashka at gmail dot com
  2010-10-25 10:18 ` siarhei.siamashka at gmail dot com
  1 sibling, 0 replies; 8+ messages in thread
From: siarhei.siamashka at gmail dot com @ 2010-10-11 19:18 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32820

Siarhei Siamashka <siarhei.siamashka at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |siarhei.siamashka at gmail
                   |                            |dot com

--- Comment #7 from Siarhei Siamashka <siarhei.siamashka at gmail dot com> 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 (
    "add    r0, %[a], #123\n"
    : [result] "=&r" (result)
    : [a]      "r"   (a)
  );
  return result;
}

$ gcc -O2 -c test.c
$ objdump -d test.o

00000000 <f>:
   0:   e280007b        add     r0, r0, #123    ; 0x7b
   4:   e1a00003        mov     r0, r3
   8:   e12fff1e        bx      lr

Here the local variable 'result' gets assigned to register r3 instead of r0
causing all kind of problems.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/32820] optimizer malfunction when mixed with asm statements
       [not found] <bug-32820-4@http.gcc.gnu.org/bugzilla/>
  2010-10-11 19:18 ` [Bug middle-end/32820] optimizer malfunction when mixed with asm statements siarhei.siamashka at gmail dot com
@ 2010-10-25 10:18 ` siarhei.siamashka at gmail dot com
  1 sibling, 0 replies; 8+ messages in thread
From: siarhei.siamashka at gmail dot com @ 2010-10-25 10:18 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32820

--- Comment #8 from Siarhei Siamashka <siarhei.siamashka at gmail dot com> 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.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/32820] optimizer malfunction when mixed with asm statements
  2007-07-19 13:16 [Bug c/32820] New: " jbuehler at spirentcom dot com
                   ` (4 preceding siblings ...)
  2007-11-26 14:10 ` steven at gcc dot gnu dot org
@ 2009-02-04  4:24 ` danglin at gcc dot gnu dot org
  5 siblings, 0 replies; 8+ messages in thread
From: danglin at gcc dot gnu dot org @ 2009-02-04  4:24 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/32820] optimizer malfunction when mixed with asm statements
  2007-07-19 13:16 [Bug c/32820] New: " jbuehler at spirentcom dot com
                   ` (3 preceding siblings ...)
  2007-08-09 11:38 ` jbuehler at spirentcom dot com
@ 2007-11-26 14:10 ` steven at gcc dot gnu dot org
  2009-02-04  4:24 ` danglin at gcc dot gnu dot org
  5 siblings, 0 replies; 8+ messages in thread
From: steven at gcc dot gnu dot org @ 2007-11-26 14:10 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/32820] optimizer malfunction when mixed with asm statements
  2007-07-19 13:16 [Bug c/32820] New: " jbuehler at spirentcom dot com
                   ` (2 preceding siblings ...)
  2007-07-25 13:28 ` jbuehler at spirentcom dot com
@ 2007-08-09 11:38 ` jbuehler at spirentcom dot com
  2007-11-26 14:10 ` steven at gcc dot gnu dot org
  2009-02-04  4:24 ` danglin at gcc dot gnu dot org
  5 siblings, 0 replies; 8+ messages in thread
From: jbuehler at spirentcom dot com @ 2007-08-09 11:38 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/32820] optimizer malfunction when mixed with asm statements
  2007-07-19 13:16 [Bug c/32820] New: " jbuehler at spirentcom dot com
  2007-07-25 13:09 ` [Bug middle-end/32820] " jbuehler at spirentcom dot com
  2007-07-25 13:22 ` jbuehler at spirentcom dot com
@ 2007-07-25 13:28 ` jbuehler at spirentcom dot com
  2007-08-09 11:38 ` jbuehler at spirentcom dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: jbuehler at spirentcom dot com @ 2007-07-25 13:28 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/32820] optimizer malfunction when mixed with asm statements
  2007-07-19 13:16 [Bug c/32820] New: " jbuehler at spirentcom dot com
  2007-07-25 13:09 ` [Bug middle-end/32820] " jbuehler at spirentcom dot com
@ 2007-07-25 13:22 ` jbuehler at spirentcom dot com
  2007-07-25 13:28 ` jbuehler at spirentcom dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: jbuehler at spirentcom dot com @ 2007-07-25 13:22 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/32820] optimizer malfunction when mixed with asm statements
  2007-07-19 13:16 [Bug c/32820] New: " jbuehler at spirentcom dot com
@ 2007-07-25 13:09 ` jbuehler at spirentcom dot com
  2007-07-25 13:22 ` jbuehler at spirentcom dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: jbuehler at spirentcom dot com @ 2007-07-25 13:09 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-10-25 10:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-32820-4@http.gcc.gnu.org/bugzilla/>
2010-10-11 19:18 ` [Bug middle-end/32820] optimizer malfunction when mixed with asm statements siarhei.siamashka at gmail dot com
2010-10-25 10:18 ` siarhei.siamashka at gmail dot com
2007-07-19 13:16 [Bug c/32820] New: " jbuehler at spirentcom dot com
2007-07-25 13:09 ` [Bug middle-end/32820] " jbuehler at spirentcom dot com
2007-07-25 13:22 ` jbuehler at spirentcom dot com
2007-07-25 13:28 ` jbuehler at spirentcom dot com
2007-08-09 11:38 ` jbuehler at spirentcom dot com
2007-11-26 14:10 ` steven at gcc dot gnu dot org
2009-02-04  4:24 ` danglin at gcc dot gnu dot 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).