VRP: rewrite the division code (to handle corner cases including 0)

Aldy Hernandez aldyh@redhat.com
Wed Oct 17 11:16:00 GMT 2018



On 8/23/18 8:51 AM, Richard Biener wrote:
> On Tue, Aug 21, 2018 at 7:35 PM Aldy Hernandez <aldyh@redhat.com> wrote:
>>
>>
>>
>> On 08/21/2018 05:46 AM, Richard Biener wrote:
>>> On Wed, Aug 15, 2018 at 3:33 AM Aldy Hernandez <aldyh@redhat.com> wrote:

>>> Yeah, nice work.  Few comments:
>>>
>>> +                              TYPE_OVERFLOW_UNDEFINED (expr_type),
>>> +                              TYPE_OVERFLOW_WRAPS (expr_type),
>>>
>>> we no longer have the third state !UNDEFINED && !WRAPS so I suggest
>>> to eliminate one for the other (just pass TYPE_OVERFLOW_UNDEFINED).
>>
>> I'm confused.  Then what shall I pass to
>> wide_int_range_multiplicative_op within wide_int_range_div?  Are you
>> expecting to pass overflow_undefined to both the overflow_undefined and
>> overflow_wraps arguments in multiplicative_op?  Or are you saying I
>> should get rid of overflow_wraps in both wide_int_range_div and
>> wide_int_range_multiplicative_op (plus all other users of
>> w_i_r_multiplicative_op)?
> 
> Yes, overflow_wraps == !overflow_undefined (well, OK, not exactly - there's
> also TYPE_OVERFLOW_TRAPS, but not for pointers).
> 
> Let's sort this out as a followup.  It somewhat felt odd / inconsistent.
> 
> I think the wide-int routines want to know whether the operation may
> overflow or not and if it may then it simply assumes wrapping behavior.
> When overflow is undefined or if it traps the overflow isn't observed
> in the result ...

As promised, here is a patch merging the TYPE_OVERFLOW_UNDEFINED and 
TYPE_OVERFLOW_WRAPS flags in the wide_int_range* routines.

OK pending tests?

Aldy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: curr.patch
Type: text/x-patch
Size: 8253 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20181017/20e5003e/attachment.bin>


More information about the Gcc-patches mailing list