mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 20:23:59 +00:00
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199570 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user