This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

-O bug in gcc-ss-20000828 (and recent) for i686-pc-linux


Here is a bug where gcc -O on i686 changes a "movl $256,%eax"
into "incl %eax" (where %eax is known to contain the value 255).
The easiest way to see this is to generate assembly code
for the program below, then change the 3 "255"s to "254"
and assemble again, then diff the two assembly files:

!       movl    $255, %eax
        cmpl    $60, %edx
        je      .L3
!       incl    %eax
        jl      .L3
        jmp     .L10

The problem is that "incl" (unlike movl) changes the condition codes
and so things go awry.  This is a strange test case, sorry,
but I couldn't figure out how to trigger this without a switch().

Tom Truscott

/* "gcc -O" results in run-time abort */
static int
foo (int i)
{
  int j;

  switch (i)
  {
      case 0:
      case 1:
      case 58: j = 255 +2; break;
      case 59: j = 255 +1; break;
      case 60: j = 255 +0; break;

      case 61:
      default: abort(); break;
  }
  return j;

}

int
main ()
{
  (void) foo (59);
  return 0;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]