[llvm] r352170 - [LoopSimplifyCFG] Fix inconsistency in blocks in loop markup
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 24 21:05:02 PST 2019
Author: mkazantsev
Date: Thu Jan 24 21:05:02 2019
New Revision: 352170
URL: http://llvm.org/viewvc/llvm-project?rev=352170&view=rev
Log:
[LoopSimplifyCFG] Fix inconsistency in blocks in loop markup
2nd part of D57095 with the same reason, just in another place. We never
fold branches that are not immediately in the current loop, but this check
is missing in `IsEdgeLive` As result, it may think that the edge in subloop is
dead while it's live. It's a pessimization in the current stance.
Differential Revision: https://reviews.llvm.org/D57147
Reviewed By: rupprecht
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
llvm/trunk/test/Transforms/LoopSimplifyCFG/live_block_marking.ll
Modified: llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp?rev=352170&r1=352169&r2=352170&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp Thu Jan 24 21:05:02 2019
@@ -239,7 +239,7 @@ private:
if (!LiveLoopBlocks.count(From))
return false;
BasicBlock *TheOnlySucc = getOnlyLiveSuccessor(From);
- return !TheOnlySucc || TheOnlySucc == To;
+ return !TheOnlySucc || TheOnlySucc == To || LI.getLoopFor(From) != &L;
};
// The loop will not be destroyed if its latch is live.
Modified: llvm/trunk/test/Transforms/LoopSimplifyCFG/live_block_marking.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopSimplifyCFG/live_block_marking.ll?rev=352170&r1=352169&r2=352170&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopSimplifyCFG/live_block_marking.ll (original)
+++ llvm/trunk/test/Transforms/LoopSimplifyCFG/live_block_marking.ll Thu Jan 24 21:05:02 2019
@@ -4,11 +4,13 @@
; RUN: opt -S -enable-loop-simplifycfg-term-folding=true -passes='require<domtree>,loop(indvars,simplify-cfg)' -debug-only=loop-simplifycfg -verify-loop-info -verify-dom-info -verify-loop-lcssa 2>&1 < %s | FileCheck %s
; RUN: opt -S -enable-loop-simplifycfg-term-folding=true -indvars -loop-simplifycfg -enable-mssa-loop-dependency=true -verify-memoryssa -debug-only=loop-simplifycfg -verify-loop-info -verify-dom-info -verify-loop-lcssa 2>&1 < %s | FileCheck %s
-; This test demonstrates a bug in live blocks markup that is only catchable in
-; inter-pass interaction.
define void @test(i1 %c) {
; CHECK-LABEL: @test(
; CHECK-NEXT: entry:
+; CHECK-NEXT: switch i32 0, label [[ENTRY_SPLIT:%.*]] [
+; CHECK-NEXT: i32 1, label [[DEAD_EXIT:%.*]]
+; CHECK-NEXT: ]
+; CHECK: entry-split:
; CHECK-NEXT: br label [[OUTER:%.*]]
; CHECK: outer:
; CHECK-NEXT: br i1 [[C:%.*]], label [[TO_FOLD:%.*]], label [[LATCH:%.*]]
@@ -25,7 +27,7 @@ define void @test(i1 %c) {
; CHECK: latch.loopexit:
; CHECK-NEXT: br label [[LATCH]]
; CHECK: latch:
-; CHECK-NEXT: br i1 true, label [[OUTER]], label [[DEAD_EXIT:%.*]]
+; CHECK-NEXT: br label [[OUTER]]
; CHECK: dead_exit:
; CHECK-NEXT: ret void
;
More information about the llvm-commits
mailing list