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]
Other format: [Raw text]

3.3.2 mips/ppc compiler bug?


Attached is a small sample of code which I do not believe is generating correct
code with the 3.3.2 compiler for mips or ppc cross compilers.  I am currently
investigating migrating our software from 2.95.3 to 3.3.2 levels of the
compiler.  The cross compiler is hosted on a linux Redhat 8.0 x86 workstation.

The code is compiled with the options -O2 -S (and for mips -mips3).   What I
notice is that when the division approach is used to generate the x and y
values, the 2.95.3 compiler generates code which does the right thing (in my
opinion) whereas the 3.3.2 compiler for both ppc and mips effectively leaves the
value received as cmdxy as input and the value passed as y to subr2 identical
which I don't believe is right.  The value passed in as x using the division for
the 3.3.2 compiler also doesn't appear correct (again in my opinion).

If I change to use a right shift (rather than the division) both the 2.95.3 and
3.3.2 compilers generate correct code.

I realize this is somewhat screwy code interleaving shifts and divides (this is
inherited code).  However, it seems reasonable that the generation of the value
of y using the division approach should not result in the same value as cmdxy.

Thanks for your help either in fix for the compiler or else in helping me to
understand why the division approach leads to the identify for cmdxy and y.


#if defined( OKAY )

void subr2( char *, int, int, int, int, int );

struct blah
{
      int a;
};

void subr( char *dest, int cmdxy, struct blah *blah, int destw )
{
   int x, y, h, w;
   int hw = blah->a;

   x = ((cmdxy>>14)<<18)>>18;
   y = (cmdxy<<18)>>18;
   h = hw >> 16;
   w = hw & 0xffff;

   subr2( dest, x, y, destw, h, w );
}

#else


void subr2( char *, int, int, int, int, int );

struct blah
{
      int a;
};

void subr( char *dest, int cmdxy, struct blah *blah, int destw )
{
   int x, y, h, w;
   int hw = blah->a;

   x = ((cmdxy>>14)<<18)/(1<<18);
   y = (cmdxy<<18)/(1<<18);
   h = hw >> 16;
   w = hw & 0xffff;

   subr2( dest, x, y, destw, h, w );
}

#endif

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