This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] optimize x - y cmp 0 with undefined overflow
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 27 May 2014 12:12:37 +0200
- Subject: Re: [RFC] optimize x - y cmp 0 with undefined overflow
- Authentication-results: sourceware.org; auth=none
- References: <1466969 dot VvFMuDKXoD at polaris> <53896104 dot oWY7sHq2zD at polaris> <CAFiYyc07qb6BtaGerCoojJercTnO4=b184O7km-rge=CyBjq2g at mail dot gmail dot com> <2973073 dot WOSPpEhgk4 at polaris>
On Tue, May 27, 2014 at 11:59 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> I'm asking to merge them (move them to fold_comparison).
>
> OK, I'll repost a first patch doing only the fold-const.c massaging.
>
>> Yeah, it would be nice to see some support. The most interesting cases
>> will be symbolic-singleton +- CST where the offset shrinks a constant offset
>> in a symbolic A +- CST (thus we don't get into any overflow issues). Thus
>> handling
>>
>> [a + 1, a + 1] - [1, 1] -> [a, a]
>>
>> for example. We get the offsetted singleton symbolic ranges from
>> conditional asserts a lot.
>
> For the case at hand, you have [x + 1, INF] for y and you want to evaluate the
> range of y - x, so you really don't want to use the range of x...
Ok. That's similar to the issue I try to address with the VRP snipped I posted
yesterday.
I'd say we still handle "basic" symbolic range ops in
extract_range_from_binary_1
but in extract_range_from_binary_expr for a symbolic op0 we try to simplify
it with both [op1, op1] and with the value-range of op1 until we get a
non-varying range as result. Not sure if it's worth restricting that
to the case
where op0s value-range refers to op1 or vice versa, and eventually only
use op1 symbolically then.
Richard.
> --
> Eric Botcazou