This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/13591] loop unrolling creates incorrect code with inline asm


------- Additional Comments From shay_gal-on at pmc-sierra dot com  2004-01-06 23:23 -------
Subject: RE:  loop unrolling creates incorrect code with inli
	ne asm

Hi Richard,

Thanks for the info, reading back over the constraints, I realized that I was confusing gcc by not adding the "+" qualifier.
Once I did, the code was generated correctly.
However, I did try using p0 as a volatile, and the code created was still not correct. It was not hoisting out of the loop, but it was not getting the dependencies correctly. Entirely my fault for not paying enough attention to the details.

And yes, this is just preloading the cache, which is why I had to resort to inline asm rather then use C code.

Thanks again for the quick response.

- Shay


   |-----Original Message-----
   |From: rsandifo at redhat dot com [mailto:gcc-bugzilla@gcc.gnu.org]
   |Sent: Tuesday, January 06, 2004 3:10 PM
   |To: Shay Gal-On
   |Subject: [Bug c/13591] loop unrolling creates incorrect 
   |code with inline
   |asm
   |
   |
   |
   |------- Additional Comments From rsandifo at redhat dot com 
   | 2004-01-06 23:10 -------
   |Subject: Re:  loop unrolling creates incorrect code with inline
   | asm
   |
   |"shay_gal-on at pmc-sierra dot com" 
   |<gcc-bugzilla@gcc.gnu.org> writes:
   |> Sorry about the typo.
   |> I get the same result when changing $4 to %4 [...]
   |
   |BTW, like I say, changing $4 to %4 isn't enough:
   |
   |    I assume it's supposed to be %4 instead,  but that's 
   |not well-formed
   |    either (%4 is an input only).
   |
   |I.e., even after changing $4 to %4, the asm still isn't 
   |valid.  You're
   |trying to modify p0, or at least the register that holds p0, without
   |telling gcc about it.  The asm statement should list p0 as both an
   |input and an output.
   |
   |Put it another way: with the asm as it is now, gcc sees 
   |something which
   |reads p0 (a loop invariant) and which writes to a0-3.  
   |Since a0-3 aren't
   |used in the loop, there's no reason not to hoist it.
   |
   |If you make p0 an input and an output, gcc will realise that the asm
   |does something different each time round.
   |
   |[ Actually, if this is just a cache preload sequence, the "m" thing
   |  is probably a red herring.  But in that case, the asm is 
   |only really
   |  being executed for its side effects, not its results, so 
   |you should
   |  probably make it "volatile" instead.  You could then get 
   |rid of the
   |  dummy() function.
   |
   |  Note that making the asm volatile would probably hide the problem
   |  you're seeing (in other words, you'd probably get away 
   |with having p0
   |  be an input only).  It'd still be wrong though: p0 really 
   |should be
   |  both an input and an output. ]
   |
   |Richard
   |
   |
   |-- 
   |
   |
   |http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13591
   |
   |------- You are receiving this mail because: -------
   |You reported the bug, or are watching the reporter.
   |


-- 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]