data-streamer-in.c (streamer_read_uhwi): Optimize single byte case...

2013-06-20  Richard Biener  <rguenther@suse.de>

	* data-streamer-in.c (streamer_read_uhwi): Optimize single
	byte case, inline streamer_read_uchar and defer section
	overrun check.

From-SVN: r200239
This commit is contained in:
Richard Biener 2013-06-20 11:33:43 +00:00 committed by Richard Biener
parent 937424c182
commit d16e9a99f9
2 changed files with 29 additions and 8 deletions

View File

@ -1,3 +1,9 @@
2013-06-20 Richard Biener <rguenther@suse.de>
* data-streamer-in.c (streamer_read_uhwi): Optimize single
byte case, inline streamer_read_uchar and defer section
overrun check.
2013-06-20 Richard Biener <rguenther@suse.de>
PR tree-optimization/57584

View File

@ -120,18 +120,33 @@ bp_unpack_string (struct data_in *data_in, struct bitpack_d *bp)
unsigned HOST_WIDE_INT
streamer_read_uhwi (struct lto_input_block *ib)
{
unsigned HOST_WIDE_INT result = 0;
int shift = 0;
unsigned HOST_WIDE_INT result;
int shift;
unsigned HOST_WIDE_INT byte;
unsigned int p = ib->p;
unsigned int len = ib->len;
while (true)
const char *data = ib->data;
result = data[p++];
if ((result & 0x80) != 0)
{
byte = streamer_read_uchar (ib);
result |= (byte & 0x7f) << shift;
shift += 7;
if ((byte & 0x80) == 0)
return result;
result &= 0x7f;
shift = 7;
do
{
byte = data[p++];
result |= (byte & 0x7f) << shift;
shift += 7;
}
while ((byte & 0x80) != 0);
}
/* We check for section overrun after the fact for performance reason. */
if (p > len)
lto_section_overrun (ib);
ib->p = p;
return result;
}