On Mon, Dec 9, 2013 at 3:03 AM, Ian Lance Taylor <iant@xxxxxxxxxx> wrote: > On Sun, Dec 8, 2013 at 4:16 AM, Bin.Cheng <amker.cheng@xxxxxxxxx> wrote: >> On Sun, Dec 8, 2013 at 9:29 AM, Ian Lance Taylor <iant@xxxxxxxxxx> wrote: >>> On Sat, Dec 7, 2013 at 1:48 AM, Bin.Cheng <amker.cheng@xxxxxxxxx> 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.