This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lto] fix integer reading thinko
- From: Nathan Froyd <froydnj at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: zadeck at naturalbridge dot com
- Date: Sat, 29 Dec 2007 12:17:02 -0800
- Subject: [lto] fix integer reading thinko
The patch below fixes a thinko when reading large signed integers from
the LTO object files.
The question you should be asking is, "Why did nobody notice this
before?" I imagine everybody else was doing their testing on an
x86{,-64} machine, where shifts greater than the word width are masked.
In this case, implicit masking produced the same result as subtracting,
but without the extra operation. (One can imagine the clever (ab)uses
of this feature.) On the PPC, however, such shifts produce 0, leading
to incorrect results.
This patch fixes 253.perlbmk on powerpc64-unknown-linux-gnu. Once
again, 176.gcc is the only benchmark not compiling on that platform; the
other benchmarks all compile and run successfully.
Committed to the LTO branch.
-Nathan
2007-12-29 Nathan Froyd <froydnj@codesourcery.com>
* lto-read.c (input_integer): Use the correct shift amount.
Index: lto-read.c
===================================================================
--- lto-read.c (revision 131213)
+++ lto-read.c (working copy)
@@ -318,7 +318,7 @@ input_integer (struct input_block *ib, t
high = -1;
}
else if (shift < (2 * HOST_BITS_PER_WIDE_INT))
- high |= - ((HOST_WIDE_INT)1 << shift);
+ high |= - ((HOST_WIDE_INT)1 << (shift - HOST_BITS_PER_WIDE_INT));
}
#ifdef LTO_STREAM_DEBUGGING