From: Bill Schmidt Date: Thu, 24 May 2012 13:52:56 +0000 (+0000) Subject: backport: re PR target/53385 ("Error: operand out of range" after changes for LSHIFT_... X-Git-Tag: releases/gcc-4.6.4~525 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5effe9093dee3f7886ab9d76b1759358748fc42b;p=thirdparty%2Fgcc.git backport: re PR target/53385 ("Error: operand out of range" after changes for LSHIFT_EXPR in vrp.c) 2012-05-24 Bill Schmidt Backport from mainline 2012-05-18 Bill Schmidt PR target/53385 * config/rs6000/rs6000.c (print_operand): Revise code that unsafely relied on signed overflow behavior. From-SVN: r187834 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 18396fa29e22..9be8483f8ca3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2012-05-24 Bill Schmidt + + Backport from mainline + 2012-05-18 Bill Schmidt + + PR target/53385 + * config/rs6000/rs6000.c (print_operand): Revise code that unsafely + relied on signed overflow behavior. + 2012-05-22 Richard Guenther Backport from mainline diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 5c101a51affa..36aba430eb93 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -15822,7 +15822,6 @@ void print_operand (FILE *file, rtx x, int code) { int i; - HOST_WIDE_INT val; unsigned HOST_WIDE_INT uval; switch (code) @@ -16263,34 +16262,17 @@ print_operand (FILE *file, rtx x, int code) case 'W': /* MB value for a PowerPC64 rldic operand. */ - val = (GET_CODE (x) == CONST_INT - ? INTVAL (x) : CONST_DOUBLE_HIGH (x)); - - if (val < 0) - i = -1; - else - for (i = 0; i < HOST_BITS_PER_WIDE_INT; i++) - if ((val <<= 1) < 0) - break; + i = clz_hwi (GET_CODE (x) == CONST_INT + ? INTVAL (x) : CONST_DOUBLE_HIGH (x)); #if HOST_BITS_PER_WIDE_INT == 32 - if (GET_CODE (x) == CONST_INT && i >= 0) + if (GET_CODE (x) == CONST_INT && i > 0) i += 32; /* zero-extend high-part was all 0's */ else if (GET_CODE (x) == CONST_DOUBLE && i == 32) - { - val = CONST_DOUBLE_LOW (x); - - gcc_assert (val); - if (val < 0) - --i; - else - for ( ; i < 64; i++) - if ((val <<= 1) < 0) - break; - } + i = clz_hwi (CONST_DOUBLE_LOW (x)) + 32; #endif - fprintf (file, "%d", i + 1); + fprintf (file, "%d", i); return; case 'x':