[PATCH] D40150: [LibCallSimplifier] fix pow(x, 0.5) -> sqrt() transforms

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 16 16:25:52 PST 2017


efriedma added a comment.

> This would be a lot simpler if we could disregard errno when we have relaxed FP math, but I'm assuming it's possible to do something like '-ffast-math -fmath-errno' and still expect errno to be set for domain errors?

nnan implies we don't care about the result in cases where it would be nan, so it's probably okay if we lower an nnan "pow(x, 0.5)" to something which never sets errno.  But there's still the underlying problem that the backend can't lower the intrinsics correctly for targets where libm sets errno, so we shouldn't generate libm intrinsics for code which isn't already using them.



================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1080
+  // TODO: There is some subset of 'fast' under which these transforms should
+  // be allowed.
+  if (!Pow->isFast())
----------------
Probably something like ninf nsz?  But let's do that in a followup.


https://reviews.llvm.org/D40150





More information about the llvm-commits mailing list