Re: [patch, Fortran] Fix PR 125914, suboptimal code for (-1.0)**integer(8)
Thomas Koenig <[email protected]> Mon, 22 Jun 2026 07:39:41 +0200
| Newsgroups | gmane.comp.gcc.patches,gmane.comp.gcc.fortran |
|---|---|
| Message-ID | <[email protected]> |
Hello Harald, Regarding the check for __builtin_powi in power_6.f90: I think it is fair to check that it is no longer in the optimized dump, but inlined; therefore I left it in. > I find your testcase power_10.f90 quite interesting. It rather tests > floating-point arithmetic and may fail at different optimization levels > because of tests like > > + if (s4 /= 2.30965209) stop 11 > (plus several more). > > Please convince yourself and also test with other compilers. > Either add a suitable tolerance, or just test what needs to be > tested. You're right. While standard Fortran and IEEE semantics would dictate that this always passes, it may not with -ffast-matth. I was also surprised to see that ifx (on godbolt) failed one test with optimization due to a small delta. I actually think this is an ifx bug, but I changed the test lines to if (abs (s8 - 2.3096522811663198_8) > 1e-13_8) stop 3 if (abs (s4 - 2.30965209) > 1e-5) stop 14 respectively. Committed as https://gcc.gnu.org/g:5b0da09f0ed5da80734c143d3ce2bacd78dc0c28 Thanks for the helpful review! Best regards Thomas