summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
diff options
context:
space:
mode:
authorArnold Schwaighofer <aschwaighofer@apple.com>2013-07-01 00:54:44 +0000
committerArnold Schwaighofer <aschwaighofer@apple.com>2013-07-01 00:54:44 +0000
commitef51cf202b26ac9a7e694b791891d66358c9a7b8 (patch)
treec708283c5d9d6dcfe6734ac2f5a31f0119ce466f /llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
parenteecacc0fadb4f1fcb2297b5dbcca5c610e8f8c21 (diff)
downloadbcm5719-llvm-ef51cf202b26ac9a7e694b791891d66358c9a7b8.tar.gz
bcm5719-llvm-ef51cf202b26ac9a7e694b791891d66358c9a7b8.zip
LoopVectorize: Math functions only read rounding mode
Math functions are mark as readonly because they read the floating point rounding mode. Because we don't vectorize loops that would contain function calls that set the rounding mode it is safe to ignore this memory read. llvm-svn: 185299
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/LoopVectorize.cpp')
-rw-r--r--llvm/lib/Transforms/Vectorize/LoopVectorize.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index f41bd28776b..e6e0f6b6ae4 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -3520,6 +3520,13 @@ bool LoopVectorizationLegality::canVectorizeMemory() {
// but is not a load, then we quit. Notice that we don't handle function
// calls that read or write.
if (it->mayReadFromMemory()) {
+ // Many math library functions read the rounding mode. We will only
+ // vectorize a loop if it contains known function calls that don't set
+ // the flag. Therefore, it is safe to ignore this read from memory.
+ CallInst *Call = dyn_cast<CallInst>(it);
+ if (Call && getIntrinsicIDForCall(Call, TLI))
+ continue;
+
LoadInst *Ld = dyn_cast<LoadInst>(it);
if (!Ld) return false;
if (!Ld->isSimple() && !IsAnnotatedParallel) {
OpenPOWER on IntegriCloud