summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/VectorUtils.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-04-06 07:04:53 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-04-06 07:04:53 +0000
commit12fd50410d970f111f4a36d567fac6c0c25d991f (patch)
treecae4a5d70777d6664b571f9b9c5cccc909416c57 /llvm/lib/Analysis/VectorUtils.cpp
parent3e0430e0a81980e179f4efe79ea2e00d5f929317 (diff)
downloadbcm5719-llvm-12fd50410d970f111f4a36d567fac6c0c25d991f.tar.gz
bcm5719-llvm-12fd50410d970f111f4a36d567fac6c0c25d991f.zip
[SLPVectorizer] Vectorizing the libm sqrt to llvm's sqrt intrinsic requires nnan
To quote the langref "Unlike sqrt in libm, however, llvm.sqrt has undefined behavior for negative numbers other than -0.0 (which allows for better optimization, because there is no need to worry about errno being set). llvm.sqrt(-0.0) is defined to return -0.0 like IEEE sqrt." This means that it's unsafe to replace sqrt with llvm.sqrt unless the call is annotated with nnan. Thanks to Hal Finkel for pointing this out! llvm-svn: 265521
Diffstat (limited to 'llvm/lib/Analysis/VectorUtils.cpp')
-rw-r--r--llvm/lib/Analysis/VectorUtils.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index aa5bb7a610c..4a6cdf973e2 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -223,7 +223,9 @@ Intrinsic::ID llvm::getIntrinsicIDForCall(CallInst *CI,
case LibFunc::sqrt:
case LibFunc::sqrtf:
case LibFunc::sqrtl:
- return checkUnaryFloatSignature(*CI, Intrinsic::sqrt);
+ if (CI->hasNoNaNs())
+ return checkUnaryFloatSignature(*CI, Intrinsic::sqrt);
+ return Intrinsic::not_intrinsic;
}
return Intrinsic::not_intrinsic;
OpenPOWER on IntegriCloud