optimizer bug with inlined x86 floor() function

Tom Truscott trt@unx.sas.com
Mon Oct 4 13:25:00 GMT 1999


Hi, "gcc version 2.96 19991004 (experimental)"
on Linux "2.2.5-15smp #1" dumps core
when compiling the following program with -O:

===================================
extern __inline double
floor (double __x)
{
  register long double __value;
  __volatile unsigned short int __cw;
  __volatile unsigned short int __cwtmp;
  __asm __volatile ("fnstcw %0":"=m" (__cw));
  __cwtmp = (__cw & 0xf3ff) | 0x0400;
  __asm __volatile ("fldcw %0"::"m" (__cwtmp));
  __asm __volatile ("frndint":"=t" (__value):"0" (__x));
  __asm __volatile ("fldcw %0"::"m" (__cw));
  return __value;
}

double x;

void
foo (int doit)
{
  if (doit)
    {
      x = floor (0.0);
      return;
    }
  x = floor (0.0);
}
===================================

The floor function is included just to clarify things,
and could replaced by "#include <math.h>"

The problem (which is causing problems in a dozen real C files)
seems to be a strcmp() on line 4958 of jump.c:
#0  strcmp (p1=0x0, p2=0x0) at ../sysdeps/generic/strcmp.c:38
#1  0x80e40c1 in rtx_renumbered_equal_p (x=0x827d958, y=0x827eb04)
    at jump.c:4958

Tom Truscott   SAS Institute Inc.   SAS Campus Drive, Cary, NC 27513
trt@sas.com    Open Systems R&D     +1 919 677 8000 x7048


More information about the Gcc-bugs mailing list