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') & 1 in fold_binary.


On Sun, Apr 24, 2005 at 11:17:09PM -0600, Jeffrey A Law wrote:
> 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

FWIW, I recently worked on a RISC port which only had shift-by-one and
shift-by-eight.  So while this particular assumption didn't bite, other
assumptions about cheap constant shifts did.

There's a lot of undocumented assumptions in the RTL optimizers about
what operations are likely to be cheap.  Unsurprisingly, they match
most modern processors... but when they don't, they're a bear to get
around.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


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