aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2013-06-20 11:33:43 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2013-06-20 11:33:43 +0000
commitd16e9a99f948b7080132e0c4830faa4f0eba712c (patch)
treecf9203d5af293ba8f6a3a702432bb6e293e1842b
parent937424c1826e89c7618bf220643974e84f91f86a (diff)
downloadgcc-d16e9a99f948b7080132e0c4830faa4f0eba712c.zip
gcc-d16e9a99f948b7080132e0c4830faa4f0eba712c.tar.gz
gcc-d16e9a99f948b7080132e0c4830faa4f0eba712c.tar.bz2
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
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/data-streamer-in.c31
2 files changed, 29 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 249ee28..caf85d1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
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
* tree-ssa-loop-niter.c (expand_simple_operations): Avoid including
SSA names into the expanded expression that take part in
diff --git a/gcc/data-streamer-in.c b/gcc/data-streamer-in.c
index e9ceb29..93fe2ff4 100644
--- a/gcc/data-streamer-in.c
+++ b/gcc/data-streamer-in.c
@@ -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;
}