[llvm] r324214 - Revert [SimplifyCFG] Relax restriction for folding unconditional branches
Serguei Katkov via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 5 01:05:44 PST 2018
Author: skatkov
Date: Mon Feb 5 01:05:43 2018
New Revision: 324214
URL: http://llvm.org/viewvc/llvm-project?rev=324214&view=rev
Log:
Revert [SimplifyCFG] Relax restriction for folding unconditional branches
The patch causes the failure of the test
compiler-rt/test/profile/Linux/counter_promo_nest.c
To unblock buildbot, revert the patch while investigation is in progress.
Differential Revision: https://reviews.llvm.org/D42691
Removed:
llvm/trunk/test/Transforms/SimplifyCFG/UncondBranchToHeader.ll
Modified:
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/trunk/test/Transforms/LoopUnroll/peel-loop.ll
llvm/trunk/test/Transforms/LoopUnswitch/2015-06-17-Metadata.ll
llvm/trunk/test/Transforms/LoopUnswitch/infinite-loop.ll
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=324214&r1=324213&r2=324214&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Mon Feb 5 01:05:43 2018
@@ -5733,12 +5733,9 @@ bool SimplifyCFGOpt::SimplifyUncondBranc
// header. (This is for early invocations before loop simplify and
// vectorization to keep canonical loop forms for nested loops. These blocks
// can be eliminated when the pass is invoked later in the back-end.)
- // Note that if BB has only one predecessor then we do not introduce new
- // backedge, so we can eliminate BB.
bool NeedCanonicalLoop =
Options.NeedCanonicalLoop &&
- (LoopHeaders && !BB->getSinglePredecessor() &&
- (LoopHeaders->count(BB) || LoopHeaders->count(Succ)));
+ (LoopHeaders && (LoopHeaders->count(BB) || LoopHeaders->count(Succ)));
BasicBlock::iterator I = BB->getFirstNonPHIOrDbg()->getIterator();
if (I->isTerminator() && BB != &BB->getParent()->getEntryBlock() &&
!NeedCanonicalLoop && TryToSimplifyUncondBranchFromEmptyBlock(BB))
Modified: llvm/trunk/test/Transforms/LoopUnroll/peel-loop.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopUnroll/peel-loop.ll?rev=324214&r1=324213&r2=324214&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopUnroll/peel-loop.ll (original)
+++ llvm/trunk/test/Transforms/LoopUnroll/peel-loop.ll Mon Feb 5 01:05:43 2018
@@ -19,8 +19,10 @@
; CHECK: store i32 2, i32* %[[INC2]], align 4
; CHECK: %[[CMP3:.*]] = icmp eq i32 %k, 3
; CHECK: br i1 %[[CMP3]], label %for.end, label %[[LOOP_PH:.*]]
-; CHECK: for.end:
-; CHECK: ret void
+; CHECK: [[LOOP_PH]]:
+; CHECK: br label %[[LOOP:.*]]
+; CHECK: [[LOOP]]:
+; CHECK: %[[IV:.*]] = phi i32 [ 3, %[[LOOP_PH]] ], [ {{.*}}, %[[LOOP]] ]
define void @basic(i32* %p, i32 %k) #0 {
entry:
@@ -66,8 +68,11 @@ for.end:
; CHECK: store i32 2, i32* %[[INC2]], align 4
; CHECK: %[[CMP3:.*]] = icmp eq i32 %k, 3
; CHECK: br i1 %[[CMP3]], label %for.end, label %[[LOOP_PH:.*]]
-; CHECK: for.end:
-; CHECK: %ret = phi i32 [ 0, %entry ], [ 1, %[[NEXT0]] ], [ 2, %[[NEXT1]] ], [ 3, %[[NEXT2]] ], [ %inc, %for.body ]
+; CHECK: [[LOOP_PH]]:
+; CHECK: br label %[[LOOP:.*]]
+; CHECK: [[LOOP]]:
+; CHECK: %[[IV:.*]] = phi i32 [ 3, %[[LOOP_PH]] ], [ %[[IV:.*]], %[[LOOP]] ]
+; CHECK: %ret = phi i32 [ 0, %entry ], [ 1, %[[NEXT0]] ], [ 2, %[[NEXT1]] ], [ 3, %[[NEXT2]] ], [ %[[IV]], %[[LOOP]] ]
; CHECK: ret i32 %ret
define i32 @output(i32* %p, i32 %k) #0 {
entry:
Modified: llvm/trunk/test/Transforms/LoopUnswitch/2015-06-17-Metadata.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopUnswitch/2015-06-17-Metadata.ll?rev=324214&r1=324213&r2=324214&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopUnswitch/2015-06-17-Metadata.ll (original)
+++ llvm/trunk/test/Transforms/LoopUnswitch/2015-06-17-Metadata.ll Mon Feb 5 01:05:43 2018
@@ -16,7 +16,7 @@ for.body:
%cmp1 = icmp eq i32 %a, 12345
br i1 %cmp1, label %if.then, label %if.else, !prof !0
; CHECK: %cmp1 = icmp eq i32 %a, 12345
-; CHECK-NEXT: br i1 %cmp1, label %for.body.us, label %for.body, !prof !0
+; CHECK-NEXT: br i1 %cmp1, label %for.body.preheader.split.us, label %for.body.preheader.split, !prof !0
if.then: ; preds = %for.body
; CHECK: for.body.us:
; CHECK: add nsw i32 %{{.*}}, 123
@@ -53,7 +53,7 @@ entry:
br label %for.body
;CHECK: entry:
;CHECK-NEXT: %cmp1 = icmp eq i32 1, 2
-;CHECK-NEXT: br i1 %cmp1, label %for.body, label %for.cond.cleanup.split, !prof !1
+;CHECK-NEXT: br i1 %cmp1, label %entry.split, label %for.cond.cleanup.split, !prof !1
;CHECK: for.body:
for.body: ; preds = %for.inc, %entry
%inc.i = phi i32 [ 0, %entry ], [ %inc, %if.then ]
Modified: llvm/trunk/test/Transforms/LoopUnswitch/infinite-loop.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopUnswitch/infinite-loop.ll?rev=324214&r1=324213&r2=324214&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopUnswitch/infinite-loop.ll (original)
+++ llvm/trunk/test/Transforms/LoopUnswitch/infinite-loop.ll Mon Feb 5 01:05:43 2018
@@ -16,7 +16,7 @@
; CHECK-NEXT: br i1 %a, label %entry.split, label %abort0.split
; CHECK: entry.split:
-; CHECK-NEXT: br i1 %b, label %for.body, label %abort1.split
+; CHECK-NEXT: br i1 %b, label %entry.split.split, label %abort1.split
; CHECK: for.body:
; CHECK-NEXT: br label %for.body
Removed: llvm/trunk/test/Transforms/SimplifyCFG/UncondBranchToHeader.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/UncondBranchToHeader.ll?rev=324213&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/SimplifyCFG/UncondBranchToHeader.ll (original)
+++ llvm/trunk/test/Transforms/SimplifyCFG/UncondBranchToHeader.ll (removed)
@@ -1,18 +0,0 @@
-; RUN: opt < %s -simplifycfg -S | FileCheck %s
-
-; Check that we can get rid of empty block leading to header
-; if it does not introduce new edge.
-define i32 @test(i32 %c) {
-entry:
- br label %header
-header:
- %i = phi i32 [0, %entry], [%i.1, %backedge]
- %i.1 = add i32 %i, 1
- %cmp = icmp slt i32 %i.1, %c
- br i1 %cmp, label %backedge, label %exit
-; CHECK-NOT: backedge:
-backedge:
- br label %header
-exit:
- ret i32 %i
-}
More information about the llvm-commits
mailing list