This is the mail archive of the 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] PR middle-end/18293: Fast-path expand_mult for 2^N

> Roger Sayle wrote:
>> Zack Weinberg wrote:
>> [We do still strength-reduce x*2 all the way to x+x, right?]
> Yes, we do.  expand_shift contains the optimization that x<<1 is x+x,
> and even that x<<2 is t=x+x,t+t on platforms where rtx_costs
> of N additions is lower than the rtx_cost of a left shift by N
> bits.

- wouldn't ever expect it to be advantageous, even on 8-bit single-bit-shift
  per cycle targets.

> I suspect that for gcc 4.1 and later we'll canonicalize to multiplication
> at the tree-level (x+x -> x*2, x<<2 -> x*4, etc...) to simplify the task
> of fold, tree-ssa and the loop optimizers.  We'll then lower these all
> back to shifts and additions during RTL expansion.

However on a similar topic, has any further thought been given to reverting:

(bool)(x & <pow2-const>) => (bool)(x >> <log2-const>)

as at best it's a target specific optimization, and generally grossly
counter productive on targets which do not shift efficiently? [and doubly
painful if the (x >> <log2-const>) expression is needlessly promoted to int
on small targets]?

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