Bug in gcc-20011231

Tom Crispin crispin@centtech.com
Fri Jan 4 11:09:00 GMT 2002


That's pretty weird.  3.0.1 on my VIA C3 box works fine without using an
IMUL: looks like somebody patched the modulus code to perform the
division using multiply by the reciprocal and got it wrong.  I don't
happen to have gcc-20011231 

If you change the code this way, does it perform the modulus using IDIV
and thus get it right?

main(int argc, char *argv[])
{
  ufix8 result;
  ufix8 i;

  for (i=2; i<7; i++)
  {
        result = val % i;
        if (result != expected)
         fprintf(stderr,"Huh? modulus is %d\n", result);
  }
  return(0);
}



Furthermore, on some processors (ours - shameless plug) 8 bit IDIV is
relatively fast - the IDIV will be within a cycle or two (plus or minus)
of the rather baroque alternative sequence.  I've added a back burner
task to see if I can write a patch for gcc to recognize when IDIV will
be preferable, at least for the C3.

Thanks

-- 
Tom Crispin
Centaur Technology
512-493-8625
crispin@centtech.com



More information about the Gcc mailing list