[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#327351: gcc-4.0: Gcc miscompiles libc on hppa - breaks rounding

retitle 327351 libc rounding is broken on HPPA
reassign  327351 libc6
tags 327351 +patch

On Sep 9, 2005, at 3:25 PM, Wesley W. Terpstra wrote:
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?
What exactly are you saying should be changed to fix it?

This code is from libc, so if I can verify what you say, I'll reassign the bug.

I tried using 
  __asm__ ("fstd %%fr0,0(%1)" : "=m" (*sw) : "r" (sw));
  sw[BYTE] |= round;
  __asm__ ("fldd 0(%0), %%fr0" : : "r" (sw), "r" (*sw));
... and it worked.

I don't understand why the *sw needs to be referenced, but you're right
that this fixes the problem. I've attached a patch to fix this in libc.

Attachment: hppa-rounding.patch
Description: Binary data

Reply to: