This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/43721] Failure to optimise (a/b) and (a%b) into single __aeabi_idivmod call
- From: "mans at mansr dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Apr 2010 21:34:36 -0000
- Subject: [Bug rtl-optimization/43721] Failure to optimise (a/b) and (a%b) into single __aeabi_idivmod call
- References: <bug-43721-17994@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from mans at mansr dot com 2010-04-14 21:34 -------
The C99 standard says this about division by zero:
The result of the / operator is the quotient from the division
of the first operand by the second; the result of the % operator
is the remainder. In both operations, if the value of the second
operand is zero, the behavior is undefined.
The ARM ABI states the following about the __aeabi_div0() function:
The *div0 functions:
- Return the value passed to them as a parameter.
- Or, return a fixed value defined by the execution environment (such as 0).
- Or, raise a signal (often SIGFPE) or throw an exception, and do not return.
[...]
The *div and *divmod functions may be inlined by a tool chain. It is
Q-o-I whether an inlined version calls *div0 out of line or returns the
values that would have been returned by a particular value-returning
version of *div0.
I interpret these as saying the application may make no assumptions about
the behaviour after a division (or modulus) by zero.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43721