This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: VRP: rewrite the division code (to handle corner cases including 0)
On 08/21/2018 03:46 AM, Richard Biener wrote:
>
> + /* If we're definitely dividing by zero, there's nothing to do. */
> + if (wide_int_range_zero_p (divisor_min, divisor_max, prec))
> + return false;
>
> I know we didn't do this before but for x / 0 we should compute UNDEFINED
> as range. With the current interfacing this special case would require handling
> in the non-wide-int caller.
No strong opinions here, just a couple notes.
If we set the result for this to VR_UNDEFINED, then it'll naturally be
handled optimistically at PHI nodes, COND_EXPRs, etc.
We'd normally get that effect via path isolation when we turn the x / 0
into a trap and simplify the CFG appropriately.
However, using VR_UNDEFINED for division by zero in VRP captures the
effect earlier which is generally a good thing.
Jeff