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

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



On Sep 9, 2005, at 3:46 PM, Falk Hueffner wrote:
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).

I don't know it either, but what you propose doesn't compile.
It complains about invalid argument when the 0() is removed.

So, this appears to work (compile and give proper results):
int
fesetround (int round)
{
  unsigned int sw[2];
  if (round & ~FE_DOWNWARD)
    /* ROUND is not a valid rounding mode.  */
    return 1;

  /* Get the current status word. */
  __asm__ ("fstd %%fr0,0(%1)" : "=m" (*sw) : "r" (sw));
  sw[0] &= ~FE_DOWNWARD;
  sw[0] |= round;
  __asm__ ("fldd 0(%1), %%fr0" :: "m" (*sw), "r" (sw));

  return 0;
}

Is this doing the right thing now?

Reply to: