This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Some wide-int review comments


On Mon, Nov 11, 2013 at 3:26 PM, Kenneth Zadeck
<zadeck@naturalbridge.com> wrote:
> On 11/11/2013 06:49 AM, Richard Biener wrote:
>>
>> On Sat, Nov 9, 2013 at 3:23 PM, Kenneth Zadeck <zadeck@naturalbridge.com>
>> wrote:
>>>
>>> On 11/08/2013 05:30 AM, Richard Sandiford wrote:
>>>>
>>>>   From tree-vrp.c:
>>>>
>>>> @@ -1893,6 +1884,10 @@ vrp_int_const_binop (enum tree_code code
>>>>        /* If the singed operation wraps then int_const_binop has done
>>>>           everything we want.  */
>>>>        ;
>>>> +  /* Signed division of -1/0 overflows and by the time it gets here
>>>> +     returns NULL_TREE.  */
>>>> +  else if (!res)
>>>> +    return NULL_TREE;
>>>>      else if ((TREE_OVERFLOW (res)
>>>>              && !TREE_OVERFLOW (val1)
>>>>              && !TREE_OVERFLOW (val2))
>>>>
>>>> Why is this case different from trunk?  Or is it a bug-fix independent
>>>> of wide-int?
>>>
>>> the api for division is different for wide-int than it was for
>>> double-int.
>>
>> But this is using a tree API (int_const_binop) that didn't change
>> (it returned NULL for / 0 previously).  So what makes us arrive here
>> now?  (I agree there is a bug in VRP, but it shouldn't manifest itself
>> only on wide-int)
>>
>> Richard.
>
> My reading of the code is that is that i changed int_const_binop to return
> null_tree for this case.

Trunk has:

    case TRUNC_DIV_EXPR:
    case FLOOR_DIV_EXPR: case CEIL_DIV_EXPR:
    case EXACT_DIV_EXPR:
      /* This is a shortcut for a common special case.  */
      if (op2.high == 0 && (HOST_WIDE_INT) op2.low > 0
          && !TREE_OVERFLOW (arg1)
          && !TREE_OVERFLOW (arg2)
          && op1.high == 0 && (HOST_WIDE_INT) op1.low >= 0)
        {
          if (code == CEIL_DIV_EXPR)
            op1.low += op2.low - 1;

          res.low = op1.low / op2.low, res.high = 0;
          break;
        }

      /* ... fall through ...  */

    case ROUND_DIV_EXPR:
      if (op2.is_zero ())
        return NULL_TREE;

so it already returns NULL_TREE on divide by zero.

> On the trunk, only rem returns null_tree for divide by 0, on the wide int
> branch, both div and rem return null tree.
>
> I know that this is going to bring on a string of questions that i do not
> remember the answers to as to why i made that change. but
> fold-const.c:int_const_binop_1 now returns null_tree and this is just
> fallout from that change.
>
> Kenny
>>>>
>>>> Thanks,
>>>> Richard
>>>
>>>
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]