Bug#327351: gcc-4.0: Gcc miscompiles libc on hppa - breaks rounding
"Wesley W. Terpstra" <wesley@terpstra.ca> writes:
> On Sep 9, 2005, at 3:11 PM, Falk Hueffner wrote:
>
> "Wesley W. Terpstra" <[[terpstra@debian.org]]> writes:
>
> __asm__ ("fstd %%fr0,0(%1)" : "=m"
> (*sw) : "r" (sw));
> sw[0] &= ~FE_DOWNWARD;
> sw[0] |= round;
> __asm__ ("fldd 0(%0),%%fr0" : : "r" (sw));
>
>
>
> This is not a bug in gcc. The second asm is not marked as
> reading *sw,
> so the store can be moved behind it, or omitted if it isn't
> needed
> elsewhere. If you access *sw, you need to tell gcc. So the bug
> is in
> whatever code contains this asm.
>
> I don't know how the __asm__ directive works... "r" isn't for read?
No, it's for register. But the point is, it only marks sw as accessed,
not *sw.
> What exactly are you saying should be changed to fix it?
Add "m"(*sw) as constraint. Probably something like
__asm__ ("fldd %0,%%fr0" : : "m"(*sw))
The first asm would also be more efficiently expressed as:
__asm__ ("fstd %%fr0,%0" : "=m"(*sw))
unless these instruction have some unusual constraints such as
requiring zero offsett (I'm not familiar with this architecture).
--
Falk
Reply to: