optimization/9735: IA-64 doesn't honor trapping math when doing final schedule

jakub@redhat.com jakub@redhat.com
Mon Feb 17 22:46:00 GMT 2003


>Number:         9735
>Category:       optimization
>Synopsis:       IA-64 doesn't honor trapping math when doing final schedule
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Mon Feb 17 22:46:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     jakub@redhat.com
>Release:        3.0 ... 3.4 20031117
>Organization:
>Environment:
ia64-*-linux*
>Description:
sched-ebb.c doesn't honor may_trap_p when scheduling
during ia64_machine_reorg, so a possibly trapping insn (in
the testcase below fcmp.lt) can be scheduled before a branch
in the same extended basic block which should protect it.
I've tried to add haifa_classify_insn (insn) == TRAP_RISKY
checks into sched-ebb.c's new_ready and init_ready_list,
but probably more changes are needed to get it working.
>How-To-Repeat:
/* { dg-do run { target ia64-*-linux* } } */
/* { dg-options "-O3" } } */

int __attribute__((noinline, const))
ret4 (float value)
{
  return 4;
}

int __attribute__((noinline, const))
ret0 (float value)
{
  return 0;
}

float __attribute__((noinline))
test (float x, float y)
{
  int clsx = ret4 (x);
  int clsy = ret0 (y);

  if (clsx == 0 || clsy == 0
      || (y < 0 && clsx == 1 && clsy == 1))
    return x - y;

  return x < y ? 0 : x - y;
}

float a = 0.0, b;

int main (void)
{
  unsigned long e;
  b = a / a;
  __asm__ __volatile__ ("mov.m %0=ar.fpsr" : "=r" (e));
  e &= ~0x7e000UL;
  __asm__ __volatile__ ("mov.m ar.fpsr=%0" :: "r" (e) : "memory");
  a = test (0, b);
  __asm__ __volatile__ ("mov.m %0=ar.fpsr" : "=r" (e));
  if (e & 0x2000)
    abort ();
  exit (0);
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list