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] Optimize byte_from_pos, pos_from_bit

> This optimizes byte_from_pos and pos_from_bit by noting that we operate
> on sizes whose computations have no intermediate (or final) overflow.
> This is the single patch necessary to get Ada to bootstrap and test
> with TYPE_IS_SIZETYPE removed.  Rather than amending size_binop
> (my original plan) I chose to optimize the above two commonly used
> accessors.
> Conveniently normalize_offset can be re-written to use pos_from_bit
> instead of inlinig it.  I also took the liberty to document the
> functions (sic).

Nice, thanks.  Could you add a blurb, in the head comment of the first function 
in which you operate under the no-overflow assumption, stating this fact and 
why this is necessary (an explicit mention of Ada isn't forbidden ;-), as well 
as a cross-reference to it in the head comment of the other function(s).

> Any comments?  Would you like different factoring of the optimization
> (I considered adding a byte_from_bitpos)?  Any idea why
> byte_from_pos is using TRUNC_DIV_EXPR (only positive offsets?) and
> pos_from_bit FLOOR_DIV_EXPR (also negative offsets?) - that seems
> inconsistent, and we fold FLOOR_DIV_EXPR of unsigned types (sizetype)
> to TRUNC_DIV_EXPR anyways.

I think that a bit position is treated as non-negative, so bitpos can use 
TRUNC_DIV_EXPR in byte_from_pos and you need to use FLOOR_MOD_EXPR to get a 
non-negative *pbitpos in pos_from_bit.  Very likely obsolete now indeed.

Eric Botcazou

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