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

Re: [patch] fold-const.c: Don't transform X & C into (X >> C') & 1in fold_binary.


On Thu, 2005-04-21 at 10:54 -0400, Kazu Hirata wrote:

> Now, I am wondering if it's worthwhile to revert the sense of your
> code.  That is, if I get x & 4 != 0 in do_jump, should I convert it to
> (x >> 2) & 1?  Jeff speculated that on some RISC machines, loading of
> constants is expensive, but if we are doing (x >> 2) & 1, we are
> loading 2 anyway (although it's as small as log2 of a constant that
> appears in x & C).
Small constants typically aren't a problem -- I'm not aware of a risc
machine that would have to use multiple instructions to encode a 
shift count for example.  The problem constants typically have some
high bits set, thus something like x & 0x20000000 might result in 
a sequence like

  sethi 0x20000000,tmpreg
  losum tmpreg(0x20000000),tmpreg
  and x, tmpreg, result

Of course, the cost of a constant is highly target dependent and we
definitely don't want to expose that level of detail to the tree
optimizers.

jeff


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