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]

[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.


2007-12-29  Nathan Froyd  <>

	* 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));

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