Speedup int_bit_from_pos

Richard Sandiford richard.sandiford@arm.com
Tue Sep 23 15:47:00 GMT 2014


Jan Hubicka <hubicka@ucw.cz> writes:
> +/* Like bit_position, but return as an integer.  It must be representable in
> +   that way (since it could be a signed value, we don't have the
> +   option of returning -1 like int_size_in_byte can.  */
> +
> +static inline HOST_WIDE_INT
> +int_bit_position (const_tree field)
> +{ 
> +  return (wi::lrshift (wi::to_offset (DECL_FIELD_OFFSET (field)), BITS_PER_UNIT_LOG)
> +	  + wi::to_offset (DECL_FIELD_BIT_OFFSET (field))).to_shwi ();
> +}

Should this be lshift (left shift) rather than lrshift (logical right shift)?

Thanks for doing this BTW.

Richard



More information about the Gcc-patches mailing list