diff options
author | Arnold Schwaighofer <aschwaighofer@apple.com> | 2014-01-19 03:18:31 +0000 |
---|---|---|
committer | Arnold Schwaighofer <aschwaighofer@apple.com> | 2014-01-19 03:18:31 +0000 |
commit | cc742dd9e4e9b625733fd0de83476da461f9efe0 (patch) | |
tree | 443927de52fa2a8410d6960720f074a7021522f8 /llvm/lib/Transforms/Vectorize | |
parent | 043949d4465f1c49557e4ac1b9a1646ed6c80312 (diff) | |
download | bcm5719-llvm-cc742dd9e4e9b625733fd0de83476da461f9efe0.tar.gz bcm5719-llvm-cc742dd9e4e9b625733fd0de83476da461f9efe0.zip |
LoopVectorizer: A reduction that has multiple uses of the reduction value is not
a reduction.
Really. Under certain circumstances (the use list of an instruction has to be
set up right - hence the extra pass in the test case) we would not recognize
when a value in a potential reduction cycle was used multiple times by the
reduction cycle.
Fixes PR18526.
radar://15851149
llvm-svn: 199570
Diffstat (limited to 'llvm/lib/Transforms/Vectorize')
-rw-r--r-- | llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index c05288bd070..695ee03ea76 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -4535,13 +4535,22 @@ bool LoopVectorizationLegality::AddReductionVar(PHINode *Phi, continue; } - // Process instructions only once (termination). + // Process instructions only once (termination). Each reduction cycle + // value must only be used once, except by phi nodes and min/max + // reductions which are represented as a cmp followed by a select. + ReductionInstDesc IgnoredVal(false, 0); if (VisitedInsts.insert(Usr)) { if (isa<PHINode>(Usr)) PHIs.push_back(Usr); else NonPHIs.push_back(Usr); - } + } else if (!isa<PHINode>(Usr) && + ((!isa<FCmpInst>(Usr) && + !isa<ICmpInst>(Usr) && + !isa<SelectInst>(Usr)) || + !isMinMaxSelectCmpPattern(Usr, IgnoredVal).IsReduction)) + return false; + // Remember that we completed the cycle. if (Usr == Phi) FoundStartPHI = true; |