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: Speedup int_bit_from_pos


On 09/19/14 22:04, Jan Hubicka wrote:
Hi,
int_bit_position is used by ipa-devirt's type walking code.  It is currently a bottleneck
since I introduced speculation into contextes (I plan to solve this by changing the
way i cache results). But this patch seems to make sense anyway: we do not need to go
through folding:
tree
bit_from_pos (tree offset, tree bitpos)
{
   if (TREE_CODE (offset) == PLUS_EXPR)
     offset = size_binop (PLUS_EXPR,
                          fold_convert (bitsizetype, TREE_OPERAND (offset, 0)),
                          fold_convert (bitsizetype, TREE_OPERAND (offset, 1)));
   else
     offset = fold_convert (bitsizetype, offset);
   return size_binop (PLUS_EXPR, bitpos,
                      size_binop (MULT_EXPR, offset, bitsize_unit_node));
}

Because all the code cares only about constant offsets, we do not need to go through fold_convert,
because all the codes go via int_bit_position that already expects result to be host wide int,
it seems to make sense to implement quick path for that.

Bootstrap/regtest x86_64 in progress, OK?

Honza

	* stor-layout.c (int_bit_from_pos): New function.
	* stor-layout.h (int_bit_from_pos): Declare.
	* tree.c (int_bit_from_pos): Use it.
Just as a note to anyone else that peeks at this code, tree_to_shwi will verify the nodes are constant during a checking build.

I'd consider a different name for the function that somehow indicates the inputs are constants.

jeff

Please consider an assert or other checking code to ensure that OFFSET and BITPOS are constants. Oh, I see that tree_to_shwi will get that checking when it

Jeff


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