This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Move some flag_unsafe_math_optimizations using simplify and match


On Thu, 20 Aug 2015, Richard Biener wrote:

On Thu, Aug 20, 2015 at 7:38 AM, Marc Glisse <marc.glisse@inria.fr> wrote:
On Thu, 20 Aug 2015, Hurugalawadi, Naveen wrote:

The following testcase does not generate "x" as needed.
====================
double t (double x)
{
x = sqrt (x) * sqrt (x);
return x;
}
====================


With -fno-math-errno, we CSE the calls to sqrt, so I would expect this to
match:

  (mult (SQRT@1 @0) @1)

Without the flag, I expect that one will apply

 (simplify
  (mult (SQRT:s @0) (SQRT:s @1))
  (SQRT (mult @0 @1)))

and then maybe we have something converting sqrt(x*x) to abs(x) or maybe
not.

ICK. I'd rather have CSE still CSE the two calls by adding some tricks regarding to errno ...

I wonder if all the unsafe math optimizations are really ok without
-fno-math-errno...

Well, on GIMPLE they will preserve the original calls because of their side-effects setting errno... on GENERIC probably not.

But we are also introducing new math calls, and I am afraid those might set errno at an unexpected place in the code...

I don't know if anyone interested in errno would ever use -funsafe-math-optimizations though.

--
Marc Glisse


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]