This is the mail archive of the gcc-patches@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]

Re: patch for rotation



  In message <199901061147.WAA01606@geoffk.wattle.id.au>you write:
  > 
  > I compiled the following procedure with egcs 1.1.1:
  > 
  > unsigned
  > rotate1(unsigned x, unsigned r)
  > {
  >   unsigned y;
  >   y = x << r | x >> 32u-r;
  >   return y;
  > }
  > 
[ ... ]
  > 
  > There are probably more places in fold() where such things should go;
  > particularly, bitwise operations are unaffected by casts and suchlike.
Yes.  There's a variety of things that fold doesn't do that it should.
Consider:

  x = ((((x)&0xffff)^(~0x7fff))+0x8000)

Which is a cute way to perform sign extension without knowing the underlying
type of x.   Right now we generate poor code since we don't fold or combine
this beast very well.  This kind of code comes up often in tools which need to
run on both 32 and 64 bit host platforms.


  > Geoffrey Keating <geoffk@ozemail.com.au>
  > 
  > ===File /home/geoffk/patches/egcs-11.diff===================
  > Wed Jan  6 22:02:44 1999  Geoff Keating  <geoffk@ozemail.com.au>
  > 
  > 	* fold-const.c (fold): Recognise a rotate by an unsigned amount.
Thanks!  Installed.

jeff


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