On 11/23/2010 12:09 PM, Joern Rennecke wrote:
> If we changed BITS_PER_UNIT into an ordinary piece-of-data 'hook', this
> would not only cost a data load from the target vector, but would also
> inhibit optimizations that replace division / modulo / multiply with shift
> or mask operations.
> So maybe we should look into having a few functional hooks that do common 
> operations, i.e.
> bits_in_units        x / BITS_PER_UNIT
> bits_in_units_ceil   (x + BITS_PER_UNIT - 1) / BITS_PER_UNIT
> bit_unit_remainder   x % BITS_PER_UNIT
> units_in_bits        x * BITS_PER_UNIT

I think actual hooks is perhaps more overhead than plain division.
At least on an x86 host, which is 99% of all running hosts.

We might be able to do better with log2_bits_per_unit as data, and
a compatibility define

#define BITS_PER_UNIT (1 << targetm.log2_bits_per_unit)

which ought to give the compiler the info it needs to optimize
the operations above into shifts.


r~

Reply via email to