From 0c1963099f350415a2d091ace8ff5f61b8592910 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 10 Apr 2008 02:07:51 +0000 Subject: [PATCH] Disable an xform we've had for a long time, pow(x,0.5) -> sqrt. This is not safe for all inputs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49458 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/SimplifyLibCalls.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Transforms/IPO/SimplifyLibCalls.cpp b/lib/Transforms/IPO/SimplifyLibCalls.cpp index f7bc59fd2ee..6e4ac5ae4ae 100644 --- a/lib/Transforms/IPO/SimplifyLibCalls.cpp +++ b/lib/Transforms/IPO/SimplifyLibCalls.cpp @@ -1179,9 +1179,17 @@ public: // pow(x, 0.0) -> 1.0 return ReplaceCallWith(CI, ConstantFP::get(CI->getType(), 1.0)); } else if (Op2C->isExactlyValue(0.5)) { + // FIXME: This is not safe for -0.0 and -inf. This can only be done when + // 'unsafe' math optimizations are allowed. + // x pow(x, 0.5) sqrt(x) + // --------------------------------------------- + // -0.0 +0.0 -0.0 + // -inf +inf NaN +#if 0 // pow(x, 0.5) -> sqrt(x) Value *Sqrt = CallInst::Create(SLC.get_sqrt(), Op1, "sqrt", CI); return ReplaceCallWith(CI, Sqrt); +#endif } else if (Op2C->isExactlyValue(1.0)) { // pow(x, 1.0) -> x return ReplaceCallWith(CI, Op1); -- 2.34.1