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: PATCH RFC: With -fnon-call-exceptions don't eliminate division by zero


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
>


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