This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Division by ZERO on GIMPLE?
- From: "Bin.Cheng" <amker dot cheng at gmail dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>, Richard Biener <richard dot guenther at gmail dot com>
- Date: Mon, 9 Dec 2013 09:57:39 +0800
- Subject: Re: Division by ZERO on GIMPLE?
- Authentication-results: sourceware.org; auth=none
- References: <CAHFci299rXsNm3R4xgM1FstEuNRtbvAOh328UoBSzRQkPAD6FA at mail dot gmail dot com> <CAKOQZ8yKcAp0nqa7nvLB5g39K787mYK=d6E7830UTwO78SP6=Q at mail dot gmail dot com> <CAHFci2-_4WWOAVyLs8PGP=oV4-cSysSiuH5QaMk3w=C3NVA2CQ at mail dot gmail dot com> <CAKOQZ8wuQmjRn2H07B-rbKx1K=KC1t2U3yboxzqmCRY0wGVPLA at mail dot gmail dot com>
On Mon, Dec 9, 2013 at 3:03 AM, Ian Lance Taylor <iant@google.com> wrote:
> On Sun, Dec 8, 2013 at 4:16 AM, Bin.Cheng <amker.cheng@gmail.com> wrote:
>> On Sun, Dec 8, 2013 at 9:29 AM, Ian Lance Taylor <iant@google.com> wrote:
>>> On Sat, Dec 7, 2013 at 1:48 AM, Bin.Cheng <amker.cheng@gmail.com> wrote:
>>>>
>>>> I just found some GIMPLE like below is generated during boostrap gcc
>>>> for x86, tree-vect-loop.c
>>>>
>>>>
>>>> <bb 637>:
>>>> # group_size_1432 = PHI <1(497), group_size_1017(660)>
>>>> # scalar_dest_1287 = PHI <scalar_dest_1228(497), scalar_dest_1012(660)>
>>>> ratio_1497 = group_size_1432 / 0;
>>>> goto <bb 501>;
>>>>
>>>> The compilation ends fine, but what is the division by 0?
>>>
>>> Pretty hard to say without more information. I just tried, and I
>>> don't see it myself. I would guess that some optimization split out
>>> the ratio == 0 case for some reason.
>>
>> It disappeared with Richard's checkin r205730. Also I am not sure is
>> why the rest of compiler can live with that code.
>
> The compiler doesn't much care if you divide by zero. Even if the
> programmer doesn't do such a thing, there are many ways that CSE can
> produce an integer division by zero. Code that divides an integer by
> zero is valid C/C++ as long as it is never executed. In fact, code
> that divides an integer by zero is valid Go even if it does get
> executed--Go defines what happens when an integer division by zero
> occurs (you get a runtime panic that can be caught). So while I
> understand that the code looks odd, there is no reason the compiler
> shouldn't be able to handle it.
Hi Ian, thanks for your explanation.
Thanks,
bin
>
> Ian
--
Best Regards.