Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8330,6 +8330,12 @@ LoopVectorizeResult LoopVectorizePass::runImpl(Function &F) {
Changed |= CFGChanged |=
simplifyLoop(L, DT, LI, SE, AC, nullptr, false /* PreserveLCSSA */);

// Loop simplification may change the CFG before processLoop() lazily requests
// BlockFrequencyAnalysis. Clear a cached CycleAnalysis so BFI recomputes it
// for the simplified CFG.
if (CFGChanged && FAM->getCachedResult<CycleAnalysis>(F))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this, we can probably revert the code from #215237

FAM->clearAnalysis<CycleAnalysis>(F);

// Build up a worklist of inner-loops to vectorize. This is necessary as
// the act of vectorizing or partially unrolling a loop creates new loops
// and can invalidate iterators across the loops.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
; RUN: opt < %s -passes='function(require<cycles>,loop-vectorize)' -disable-output

; LoopVectorize simplifies loops before processing them. If CycleAnalysis was
; cached before the pass, it must not be reused after loop simplification
; changes the CFG when BlockFrequencyInfo is requested lazily.

define i16 @f(i1 %c) {
entry:
br label %header

latch:
%iv.next = add i16 %iv, 1
%done = icmp eq i16 %iv.next, 0
br i1 %done, label %second, label %header

header:
%iv = phi i16 [ 0, %entry ], [ %iv.next, %latch ]
br i1 %c, label %trap, label %latch

trap:
unreachable

second:
br i1 false, label %second, label %second
}