public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Bin.Cheng" <amker.cheng@gmail.com>
To: Ian Lance Taylor <iant@google.com>
Cc: "gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>,
	Richard Biener <richard.guenther@gmail.com>
Subject: Re: Division by ZERO on GIMPLE?
Date: Mon, 09 Dec 2013 01:57:00 -0000	[thread overview]
Message-ID: <CAHFci29_+V=9vOtScOJQ2WqPRg98byQaiOLixE17FeGexm+0dg@mail.gmail.com> (raw)
In-Reply-To: <CAKOQZ8wuQmjRn2H07B-rbKx1K=KC1t2U3yboxzqmCRY0wGVPLA@mail.gmail.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.

  reply	other threads:[~2013-12-09  1:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-07  9:48 Bin.Cheng
2013-12-08  1:29 ` Ian Lance Taylor
2013-12-08 12:17   ` Bin.Cheng
2013-12-08 12:47     ` Bin.Cheng
2013-12-08 19:04     ` Ian Lance Taylor
2013-12-09  1:57       ` Bin.Cheng [this message]
2013-12-09  3:26     ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHFci29_+V=9vOtScOJQ2WqPRg98byQaiOLixE17FeGexm+0dg@mail.gmail.com' \
    --to=amker.cheng@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=iant@google.com \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).