summaryrefslogtreecommitdiff
path: root/lib/Transforms/Vectorize/LoopVectorize.cpp
diff options
context:
space:
mode:
authorAyal Zaks <ayal.zaks@intel.com>2017-09-13 06:28:37 +0000
committerAyal Zaks <ayal.zaks@intel.com>2017-09-13 06:28:37 +0000
commit3c0fd8c54bac789e5481f466067c213f6af90182 (patch)
tree6decf4b7238ab77c20285e8bacf316d4350e0871 /lib/Transforms/Vectorize/LoopVectorize.cpp
parentf844eaced2fd24719e8ad752a85932df49547baf (diff)
[LV] Fix PR34523 - avoid generating redundant selects
When converting a PHI into a series of 'select' instructions to combine the incoming values together according their edge masks, initialize the first value to the incoming value In0 of the first predecessor, instead of generating a redundant assignment 'select(Cond[0], In0, In0)'. The latter fails when the Cond[0] mask is null, representing a full mask, which can happen only when there's a single incoming value. No functional changes intended nor expected other than surviving null Cond[0]'s. This fix follows D35725, which introduced using null to represent full masks. Differential Revision: https://reviews.llvm.org/D37619 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313119 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Vectorize/LoopVectorize.cpp')
-rw-r--r--lib/Transforms/Vectorize/LoopVectorize.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp
index 5267a2a3f19..487a7fb72f0 100644
--- a/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4526,10 +4526,10 @@ void InnerLoopVectorizer::widenPHIInstruction(Instruction *PN, unsigned UF,
for (unsigned Part = 0; Part < UF; ++Part) {
Value *In0 = getOrCreateVectorValue(P->getIncomingValue(In), Part);
- // We might have single edge PHIs (blocks) - use an identity
- // 'select' for the first PHI operand.
+ assert((Cond[Part] || NumIncoming == 1) &&
+ "Multiple predecessors with one predecessor having a full mask");
if (In == 0)
- Entry[Part] = Builder.CreateSelect(Cond[Part], In0, In0);
+ Entry[Part] = In0; // Initialize with the first incoming value.
else
// Select between the current value and the previous incoming edge
// based on the incoming mask.