On Tue, Nov 29, 2016 at 03:08:15PM +0100, Markus Trippelsdorf wrote: > Building gcc with -fsanitize=undefined shows: > rtlanal.c:5210:38: runtime error: shift exponent 4294967295 is too > large for 64-bit type 'long unsigned int' > > 5210 return nonzero & (HOST_WIDE_INT_1U << (bitwidth - 1)) > 5211 ? 1 : bitwidth - floor_log2 (nonzero) - 1; > > Here (bitwidth - 1) wraps around because bitwidth is zero and unsigned.
Which modes have precision of 0? I'd expect just VOIDmode and BLKmode, any others? And for those I'd say it is a bug to call num_sign_bit_copies*. > Tested on ppc64le. > OK for trunk? > > Thanks. > > * rtlanal.c (num_sign_bit_copies1): Check for zero bitwidth. > > diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c > index 4e4eb2ef3458..918088a0db8e 100644 > --- a/gcc/rtlanal.c > +++ b/gcc/rtlanal.c > @@ -5203,7 +5203,7 @@ num_sign_bit_copies1 (const_rtx x, machine_mode mode, > const_rtx known_x, > safely compute the mask for this mode, always return BITWIDTH. */ > > bitwidth = GET_MODE_PRECISION (mode); > - if (bitwidth > HOST_BITS_PER_WIDE_INT) > + if (bitwidth == 0 || bitwidth > HOST_BITS_PER_WIDE_INT) > return 1; > > nonzero = nonzero_bits (x, mode); > > -- > Markus Jakub