This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] rs6000: Follow up for signed integer overflow fix
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Markus Trippelsdorf <markus at trippelsdorf dot de>
- Cc: David Edelsohn <dje dot gcc at gmail dot com>, Richard Biener <rguenther at suse dot de>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 20 Nov 2014 19:44:07 +0100
- Subject: Re: [PATCH] rs6000: Follow up for signed integer overflow fix
- Authentication-results: sourceware.org; auth=none
- References: <20141120132752 dot GJ344 at x4> <CAGWvnymUOubGwo73Lhxjphw0T+GH0YvX5HwOmm0vLa_mfZ10cA at mail dot gmail dot com> <20141120184143 dot GK344 at x4>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Thu, Nov 20, 2014 at 07:41:43PM +0100, Markus Trippelsdorf wrote:
> 2014-11-20 Markus Trippelsdorf <markus@trippelsdorf.de>
>
> * config/rs6000/rs6000.c (includes_rldic_lshift_p): Cast 0 to unsigned.
> (includes_rldicr_lshift_p): Likewise.
>
> diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> index a9604cf3fa97..d7958b33ba1a 100644
> --- a/gcc/config/rs6000/rs6000.c
> +++ b/gcc/config/rs6000/rs6000.c
> @@ -16197,10 +16197,10 @@ includes_rldic_lshift_p (rtx shiftop, rtx andop)
> unsigned HOST_WIDE_INT c, lsb, shift_mask;
>
> c = INTVAL (andop);
> - if (c == 0 || c == ~0)
> + if (c == 0 || c == ~(unsigned HOST_WIDE_INT) 0)
> return 0;
>
> - shift_mask = ~0;
> + shift_mask = ~(unsigned HOST_WIDE_INT) 0;
> shift_mask <<= INTVAL (shiftop);
>
> /* Find the least significant one bit. */
> @@ -16235,7 +16235,7 @@ includes_rldicr_lshift_p (rtx shiftop, rtx andop)
> {
> unsigned HOST_WIDE_INT c, lsb, shift_mask;
>
> - shift_mask = ~0;
> + shift_mask = ~(unsigned HOST_WIDE_INT) 0;
> shift_mask <<= INTVAL (shiftop);
> c = INTVAL (andop);
You could use ~HOST_WIDE_INT_UC (0) in all the 3 cases.
Jakub