http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43716



--- Comment #49 from richard.guenther at gmail dot com <richard.guenther at 
gmail dot com> 2013-01-09 08:52:21 UTC ---

On Tue, Jan 8, 2013 at 8:52 PM, dominiq at lps dot ens.fr

<gcc-bugzi...@gcc.gnu.org> wrote:

>

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43716

>

> --- Comment #48 from Dominique d'Humieres <dominiq at lps dot ens.fr> 
> 2013-01-08 19:52:39 UTC ---

> From comment #40:

>

>> with -ffast-math, so for example

>>

>>   if (x != 0)

>>     tem = y / x;

>>   else

>>     tem = 0.;

>>   ... do sth with tem ...

>>

>> will execute y / x unconditionally based on the fact that it cannot trap.

>

> This optimization generates an exception trapped when using -ffpe-trap=invalid

> along with -ffast-math.

> This unfortunately prevents any debugging based -ffpe-trap=invalid for

> miscompilations occurring with -ffast-math.



Well - that's maybe unfortunate but expected.  You can't have both ;)



> One thing I hope, though I am not

> sure about it, is that the above block is still compiled as

>

> tem=y/x

> if (x==0) tem=0.



Yes, it's basically turned into an unconditional divide plus a conditional move

based on the fact that we cannot vectorize non-straight-line-code (so

it's really

only a vectorization enabler).



> My original report was for '-O3 -funsafe-math-optimizations 
> -ffinite-math-only'

> without -ffpe-trap=invalid. The segmentation fault resulted from the fact that

> some variables were used to access a table and were out of bound when the

> miscompilation generated some NAN (see comment #13).



Yes, that's another common issue - with FP indexing even slight

rounding differences can cause bogus accesses (consider producing

a[0.99] instead of a[1.0]).  That mostly happens with FP loop induction

variables that are also used for indexing (a really bad practice the frontend

should warn about - at least when -funsafe-math-optimizations is in effect).



Richard.



> --

> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email

> ------- You are receiving this mail because: -------

> You are on the CC list for the bug.

Reply via email to