summaryrefslogtreecommitdiff
path: root/lib/Transforms/Vectorize
diff options
context:
space:
mode:
authorArnold Schwaighofer <aschwaighofer@apple.com>2013-10-07 21:05:43 +0000
committerArnold Schwaighofer <aschwaighofer@apple.com>2013-10-07 21:05:43 +0000
commit1ee3c0008be6f7012aa69f7a73a2819300bdf23f (patch)
tree6603eb4dc1458fae0bd918409ef74e8e363cc168 /lib/Transforms/Vectorize
parent42be15fcbeedaa67c4b5f4b19eb273749ae36465 (diff)
downloadllvm-1ee3c0008be6f7012aa69f7a73a2819300bdf23f.tar.gz
llvm-1ee3c0008be6f7012aa69f7a73a2819300bdf23f.tar.bz2
llvm-1ee3c0008be6f7012aa69f7a73a2819300bdf23f.tar.xz
LoopVectorize: External uses must use the last value in a reduction cycle
Otherwise, we don't perform operations that would have been performed on the scalar version. Fixes PR17498. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192133 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Vectorize')
-rw-r--r--lib/Transforms/Vectorize/LoopVectorize.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp
index a71df08aba..415f86e893 100644
--- a/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4015,6 +4015,12 @@ bool LoopVectorizationLegality::AddReductionVar(PHINode *Phi,
if (ExitInstruction != 0 || Cur == Phi)
return false;
+ // The instruction used by an outside user must be the last instruction
+ // before we feed back to the reduction phi. Otherwise, we loose VF-1
+ // operations on the value.
+ if (std::find(Phi->op_begin(), Phi->op_end(), Cur) == Phi->op_end())
+ return false;
+
ExitInstruction = Cur;
continue;
}