------- Comment #2 from rearnsha at gcc dot gnu dot org  2009-03-16 23:27 
-------
I believe this is a bug in the way we expand local reg vars.  The manual says:

Local register variables in specific registers do not reserve the
registers, except at the point where they are used as input or output
operands in an @code{asm} statement and the @code{asm} statement itself is
not deleted.  The compiler's data flow analysis is capable of determining
where the specified registers contain live values, and where they are
available for other uses.

There are two key points to note in the above: 1) The only point at which a
register variable *has* to be in the named register is when an inline ASM
appears.  2) Data flow is supposed to know when the value is live.  I thus
believe we need to expand local vars as used in this test-case by copying a
pseudo reg that contains the real value into the required register immediately
before its use in an ASM -- and to leave optimizing this code path to the
register allocator -- so that ideally no copy is necessary.

In the test-case cited, the user assigns the variable r0 with a value and then
tries to assign another value to the variable r1.  The second step requires a
libcall sequence that clobbers the value previously stored into r0 -- to avoid
this happening the value previously assigned must be copied to a call-saved
register (or the assignment deferred until after the libcall).


-- 

rearnsha at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rearnsha at gcc dot gnu dot
                   |                            |org, ramana dot r at gmail
                   |                            |dot com
             Status|UNCONFIRMED                 |NEW
          Component|target                      |inline-asm
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2009-03-16 23:27:22
               date|                            |


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

Reply via email to