On Tue, Jul 19, 2016 at 2:58 PM, Jakub Jelinek <ja...@redhat.com> wrote:
> On Tue, Jul 19, 2016 at 02:46:46PM +0200, Uros Bizjak wrote:
>> The result of exercises with sed in gcc/ directory.
>>
>> 2016-07-19  Uros Bizjak  <ubiz...@gmail.com>
>>
>>     * builtins.c: Use HOST_WIDE_INT_1 instead of (HOST_WIDE_INT) 1,
>>     HOST_WIDE_INT_1U instead of (unsigned HOST_WIDE_INT) 1,
>>     HOST_WIDE_INT_M1 instead of (HOST_WIDE_INT) -1 and
>>     HOST_WIDE_INT_M1U instead of (unsigned HOST_WIDE_INT) -1.
>>     * combine.c: Ditto.
>>     * cse.c: Ditto.
>>     * dojump.c: Ditto.
>>     * double-int.c: Ditto.
>>     * dse.c: Ditto.
>>     * dwarf2out.c: Ditto.
>>     * expmed.c: Ditto.
>>     * expr.c: Ditto.
>>     * fold-const.c: Ditto.
>>     * function.c: Ditto.
>>     * fwprop.c: Ditto.
>>     * genmodes.c: Ditto.
>>     * hwint.c: Ditto.
>>     * hwint.h: Ditto.
>>     * ifcvt.c: Ditto.
>>     * loop-doloop.c: Ditto.
>>     * loop-invariant.c: Ditto.
>>     * loop-iv.c: Ditto.
>>     * match.pd: Ditto.
>>     * optabs.c: Ditto.
>>     * real.c: Ditto.
>>     * reload.c: Ditto.
>>     * rtlanal.c: Ditto.
>>     * simplify-rtx.c: Ditto.
>>     * stor-layout.c: Ditto.
>>     * toplev.c: Ditto.
>>     * tree-ssa-loop-ivopts.c: Ditto.
>>     * tree-vect-generic.c: Ditto.
>>     * tree-vect-patterns.c: Ditto.
>>     * tree.c: Ditto.
>>     * tree.h: Ditto.
>>     * ubsan.c: Ditto.
>>     * varasm.c: Ditto.
>>     * wide-int-print.cc: Ditto.
>>     * wide-int.cc: Ditto.
>>     * wide-int.h: Ditto.
>>
>> Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.
>>
>> OK for mainline?
>
>> @@ -546,7 +546,7 @@ div_and_round_double (unsigned code, int uns,
>>        if (quo_neg && (*lrem != 0 || *hrem != 0))   /* ratio < 0 && rem != 0 
>> */
>>       {
>>         /* quo = quo - 1;  */
>> -       add_double (*lquo, *hquo, (HOST_WIDE_INT) -1, (HOST_WIDE_INT)  -1,
>> +       add_double (*lquo, *hquo, HOST_WIDE_INT_M1, (HOST_WIDE_INT)  -1,
>>                     lquo, hquo);
>>       }
>>        else
>
> This surely should be
>           add_double (*lquo, *hquo, HOST_WIDE_INT_M1, HOST_WIDE_INT_M1,
>                       lquo, hquo);

Thanks, the repacement regexp missed the second one due to extra space. Fixed.

>> @@ -557,7 +557,7 @@ div_and_round_double (unsigned code, int uns,
>>      case CEIL_MOD_EXPR:              /* round toward positive infinity */
>>        if (!quo_neg && (*lrem != 0 || *hrem != 0))  /* ratio > 0 && rem != 0 
>> */
>>       {
>> -       add_double (*lquo, *hquo, (HOST_WIDE_INT) 1, (HOST_WIDE_INT) 0,
>> +       add_double (*lquo, *hquo, HOST_WIDE_INT_1, (HOST_WIDE_INT) 0,
>>                     lquo, hquo);
>>       }
>>        else
>
> Dunno here, either just use 0 instead of (HOST_WIDE_INT) 0, or define
> HOST_WIDE_INT_0 macro and use that?  Though as add_double is a macro
> that in the end calls a function with UHWI or HWI arguments, I wonder what is 
> the
> point in all these casts, whether just using -1, -1, or 1, 0, etc. wouldn't
> be better.

I didn't want to add more complex cases (e.g. ~(unsigned
HOST_WIDE_INT) 0 to the patch, just the trivial replacements. I will
submit a follow-up patch that converts these cases. The patch will be
much shorter, but there are some cases that are non-trivial.

>> @@ -590,10 +590,10 @@ div_and_round_double (unsigned code, int uns,
>>           if (quo_neg)
>>             /* quo = quo - 1;  */
>>             add_double (*lquo, *hquo,
>> -                       (HOST_WIDE_INT) -1, (HOST_WIDE_INT) -1, lquo, hquo);
>> +                       HOST_WIDE_INT_M1, HOST_WIDE_INT_M1, lquo, hquo);
>>           else
>>             /* quo = quo + 1; */
>> -           add_double (*lquo, *hquo, (HOST_WIDE_INT) 1, (HOST_WIDE_INT) 0,
>> +           add_double (*lquo, *hquo, HOST_WIDE_INT_1, (HOST_WIDE_INT) 0,
>>                         lquo, hquo);
>>         }
>>       else
>
>> diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
>> index f5c530a..4354b5b 100644
>> --- a/gcc/simplify-rtx.c
>> +++ b/gcc/simplify-rtx.c
>> @@ -40,7 +40,7 @@ along with GCC; see the file COPYING3.  If not see
>>     occasionally need to sign extend from low to high as if low were a
>>     signed wide int.  */
>>  #define HWI_SIGN_EXTEND(low) \
>> - ((((HOST_WIDE_INT) low) < 0) ? ((HOST_WIDE_INT) -1) : ((HOST_WIDE_INT) 0))
>> + ((((HOST_WIDE_INT) low) < 0) ? HOST_WIDE_INT_M1 : ((HOST_WIDE_INT) 0))
>>
>>  static rtx neg_const_int (machine_mode, const_rtx);
>>  static bool plus_minus_operand_p (const_rtx);
>
> But then here we have yet another (HOST_WIDE_INT) 0 - HOST_WIDE_INT_0
> candidate.

I will submit yet another patch introducing HOST_WIDE_INT_0.

> Otherwise LGTM.

Thanks! Committed with the above mentioned fix.

Uros.

Reply via email to