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: David Edelsohn <dje dot gcc at gmail dot com>
- To: Markus Trippelsdorf <markus at trippelsdorf dot de>
- Cc: Jakub Jelinek <jakub at redhat 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:31:58 -0500
- 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> <20141120184407 dot GY1745 at tucnak dot redhat dot com> <20141120185843 dot GL344 at x4>
On Thu, Nov 20, 2014 at 1:58 PM, Markus Trippelsdorf
<markus@trippelsdorf.de> wrote:
> On 2014.11.20 at 19:44 +0100, Jakub Jelinek wrote:
>> 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.
>
> Or better still HOST_WIDE_INT_M1U.
Okay.
Thanks, David