> From: Jakub Jelinek [mailto:ja...@redhat.com] > Sent: Thursday, June 19, 2014 1:54 AM > > Seems there are actually two spots with this, not just one. > > Completely untested fix: > > 2014-06-18 Jakub Jelinek <ja...@redhat.com> > > * tree-ssa-math-opts.c (do_shift_rotate, find_bswap_or_nop_1): > Cast > 0xff to uint64_t before shifting it up. > > --- gcc/tree-ssa-math-opts.c 2014-06-13 08:08:42.354136356 +0200 > +++ gcc/tree-ssa-math-opts.c 2014-06-18 19:50:59.486916201 +0200 > @@ -1669,7 +1669,8 @@ do_shift_rotate (enum tree_code code, > break; > case RSHIFT_EXPR: > /* Arithmetic shift of signed type: result is dependent on the value. > */ > - if (!TYPE_UNSIGNED (n->type) && (n->n & (0xff << (bitsize - 8)))) > + if (!TYPE_UNSIGNED (n->type) > + && (n->n & ((uint64_t) 0xff << (bitsize - 8)))) > return false; > n->n >>= count; > break; > @@ -1903,7 +1904,7 @@ find_bswap_or_nop_1 (gimple stmt, struct > old_type_size = TYPE_PRECISION (n->type); > if (!TYPE_UNSIGNED (n->type) > && type_size > old_type_size > - && n->n & (0xff << (old_type_size - 8))) > + && n->n & ((uint64_t) 0xff << (old_type_size - 8))) > return NULL_TREE; > > if (type_size / BITS_PER_UNIT < (int)(sizeof (int64_t))) > >
Yep, that's the right fix. I tested it on both a bootstrapped gcc on x86_64-linux-gnu and an arm-none-eabi cross-compiler with no regression on the testsuite. Jakub, since you made the patch, the honor of commiting it should be yours. Richard, given this issue, I think we should wait a few more days before I commit A backported (and fixed of course) version to 4.8 and 4.9. Best regards, Thomas