summaryrefslogtreecommitdiff
path: root/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
commitc14380d1953acd5a735e1d8bcf18d0f96876da74 (patch)
treeb10d536e874fee69c772bf198cfae53df04fa311 /lib/Transforms/Vectorize/LoopVectorize.cpp
parentc36a8d2b3d6e543de8d9f210ecd39a9a0641d826 (diff)
downloadllvm-c14380d1953acd5a735e1d8bcf18d0f96876da74.tar.gz
llvm-c14380d1953acd5a735e1d8bcf18d0f96876da74.tar.bz2
llvm-c14380d1953acd5a735e1d8bcf18d0f96876da74.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185299 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Vectorize/LoopVectorize.cpp')
-rw-r--r--lib/Transforms/Vectorize/LoopVectorize.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp
index f41bd28776..e6e0f6b6ae 100644
--- a/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/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) {