Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LoopUnroll] Support loops with exiting block that is neither header nor
latch. Summary: Remove the limitation in LoopUnrollPass that exiting block must be either header or latch. Reviewer: dmgreen, jdoerfert, Meinersbur, kbarton, bmahjour, etiotto, fhahn, efriedma Reviewed By: etiotto, fhahn, efriedma Subscribers: efriedma, lkail, xbolva00, hiraditya, zzheng, llvm-commits Tag: LLVM Differential Revision: https://reviews.llvm.org/D80477
- Loading branch information
Whitney Tsang
committed
May 29, 2020
1 parent
b4668a2
commit 1bc73b0
Showing
2 changed files
with
109 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
; RUN: opt < %s -loop-unroll -S | FileCheck %s | ||
; RUN: opt < %s -passes='require<opt-remark-emit>,unroll' -S | FileCheck %s | ||
|
||
define void @foo(i32* noalias %A) { | ||
; CHECK-LABEL: @foo( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[A:%.*]], align 4 | ||
; CHECK-NEXT: call void @bar(i32 [[TMP0]]) | ||
; CHECK-NEXT: br label [[FOR_HEADER:%.*]] | ||
; CHECK: for.header: | ||
; CHECK-NEXT: call void @bar(i32 [[TMP0]]) | ||
; CHECK-NEXT: br label [[FOR_BODY:%.*]] | ||
; CHECK: for.body: | ||
; CHECK-NEXT: br label [[FOR_BODY_FOR_BODY_CRIT_EDGE:%.*]] | ||
; CHECK: for.body.for.body_crit_edge: | ||
; CHECK-NEXT: [[ARRAYIDX_PHI_TRANS_INSERT:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 1 | ||
; CHECK-NEXT: [[DOTPRE:%.*]] = load i32, i32* [[ARRAYIDX_PHI_TRANS_INSERT]], align 4 | ||
; CHECK-NEXT: call void @bar(i32 [[DOTPRE]]) | ||
; CHECK-NEXT: br label [[FOR_BODY_1:%.*]] | ||
; CHECK: for.end: | ||
; CHECK-NEXT: ret void | ||
; CHECK: for.body.1: | ||
; CHECK-NEXT: br label [[FOR_BODY_FOR_BODY_CRIT_EDGE_1:%.*]] | ||
; CHECK: for.body.for.body_crit_edge.1: | ||
; CHECK-NEXT: [[ARRAYIDX_PHI_TRANS_INSERT_1:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 2 | ||
; CHECK-NEXT: [[DOTPRE_1:%.*]] = load i32, i32* [[ARRAYIDX_PHI_TRANS_INSERT_1]], align 4 | ||
; CHECK-NEXT: call void @bar(i32 [[DOTPRE_1]]) | ||
; CHECK-NEXT: br label [[FOR_BODY_2:%.*]] | ||
; CHECK: for.body.2: | ||
; CHECK-NEXT: br label [[FOR_BODY_FOR_BODY_CRIT_EDGE_2:%.*]] | ||
; CHECK: for.body.for.body_crit_edge.2: | ||
; CHECK-NEXT: [[ARRAYIDX_PHI_TRANS_INSERT_2:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 3 | ||
; CHECK-NEXT: [[DOTPRE_2:%.*]] = load i32, i32* [[ARRAYIDX_PHI_TRANS_INSERT_2]], align 4 | ||
; CHECK-NEXT: call void @bar(i32 [[DOTPRE_2]]) | ||
; CHECK-NEXT: br label [[FOR_BODY_3:%.*]] | ||
; CHECK: for.body.3: | ||
; CHECK-NEXT: br i1 false, label [[FOR_BODY_FOR_BODY_CRIT_EDGE_3:%.*]], label [[FOR_END:%.*]] | ||
; CHECK: for.body.for.body_crit_edge.3: | ||
; CHECK-NEXT: [[ARRAYIDX_PHI_TRANS_INSERT_3:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 4 | ||
; CHECK-NEXT: unreachable | ||
; | ||
entry: | ||
%0 = load i32, i32* %A, align 4 | ||
call void @bar(i32 %0) | ||
br label %for.header | ||
|
||
for.header: | ||
%1 = phi i32 [ %0, %entry ], [ %.pre, %for.body.for.body_crit_edge ] | ||
%i = phi i64 [ 0, %entry ], [ %inc, %for.body.for.body_crit_edge ] | ||
%arrayidx = getelementptr inbounds i32, i32* %A, i64 %i | ||
call void @bar(i32 %1) | ||
br label %for.body | ||
|
||
for.body: | ||
%inc = add nsw i64 %i, 1 | ||
%cmp = icmp slt i64 %inc, 4 | ||
br i1 %cmp, label %for.body.for.body_crit_edge, label %for.end | ||
|
||
for.body.for.body_crit_edge: | ||
%arrayidx.phi.trans.insert = getelementptr inbounds i32, i32* %A, i64 %inc | ||
%.pre = load i32, i32* %arrayidx.phi.trans.insert, align 4 | ||
br label %for.header | ||
|
||
for.end: | ||
ret void | ||
} | ||
|
||
declare void @bar(i32) |