[lto] fix integer reading thinko

Kenneth Zadeck zadeck@naturalbridge.com
Sat Dec 29 22:35:00 GMT 2007


Nathan Froyd wrote:
> 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
>   
thanks

kenny



More information about the Gcc-patches mailing list