This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH RFC: With -fnon-call-exceptions don't eliminate division by zero
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: Ian Lance Taylor <iant at google dot com>, gcc-patches at gcc dot gnu dot org
- Date: Tue, 12 Oct 2010 12:22:13 +0200
- Subject: Re: PATCH RFC: With -fnon-call-exceptions don't eliminate division by zero
- References: <mcrhbgswhuk.fsf@google.com> <201010121000.42449.ebotcazou@adacore.com>
On Tue, Oct 12, 2010 at 10:00 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> The -fnon-call-exceptions options indicates that certain operations,
>> including division by zero, should generate an exception. ?This includes
>> cases like 0 / 0. ?This patch ensures that 0 / 0 and any other division
>> by zero is not eliminated when -fnon-call-exceptions is used.
>
> You must test cfun->can_throw_non_call_exceptions instead on the mainline.
Indeed. Also I think your test is only trying to avoid optimization that
happens downstream and is not a proper test for what it should test.
It seems to be a proper test would be
+ if ((code == TRUNC_DIV_EXPR
+ || code == FLOOR_DIV_EXPR
+ || code == CEIL_DIV_EXPR
+ || code == EXACT_DIV_EXPR
+ || code == ROUND_DIV_EXPR)
&& cfun->can_throw_non_call_exceptions
&& (vr1.type != VR_RANGE
|| symbolic_range_p (&vr1)
|| range_includes_zero_p (&vr1)))
which conservatively tests whether the range does include zero.
If you only want to constrain the downstream optimization please
instead integrate the tests into their respective predicates.
Thanks,
Richard.
> --
> Eric Botcazou
>