diff options
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp index ff35db14f709..fdfff1613209 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp @@ -293,9 +293,8 @@ void LoopVectorizeHints::getHintsFromMetadata() { } void LoopVectorizeHints::setHint(StringRef Name, Metadata *Arg) { - if (!Name.starts_with(Prefix())) + if (!Name.consume_front(Prefix())) return; - Name = Name.substr(Prefix().size(), StringRef::npos); const ConstantInt *C = mdconst::dyn_extract<ConstantInt>(Arg); if (!C) @@ -1643,6 +1642,19 @@ bool LoopVectorizationLegality::canVectorizeLoopCFG(Loop *Lp, return false; } + // The latch must be terminated by a BranchInst. + BasicBlock *Latch = Lp->getLoopLatch(); + if (Latch && !isa<BranchInst>(Latch->getTerminator())) { + reportVectorizationFailure( + "The loop latch terminator is not a BranchInst", + "loop control flow is not understood by vectorizer", "CFGNotUnderstood", + ORE, TheLoop); + if (DoExtraAnalysis) + Result = false; + else + return false; + } + return Result; } |
