forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SCEV] Handling for ICmp occuring in the evolution chain.
Summary: If a compare instruction is same or inverse of the compare in the branch of the loop latch, then return a constant evolution node. This shall facilitate computations of loop exit counts in cases where compare appears in the evolution chain of induction variables. Will fix PR 34538 Reviewers: sanjoy, hfinkel, junryoungju Reviewed By: sanjoy, junryoungju Subscribers: javed.absar, llvm-commits Differential Revision: https://reviews.llvm.org/D38494 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318050 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Showing
3 changed files
with
127 additions
and
8 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
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,39 @@ | ||
; RUN: opt -scalar-evolution -loop-deletion -simplifycfg -analyze < %s | FileCheck %s --check-prefix=CHECK-ANALYSIS-1 | ||
; RUN: opt -analyze -scalar-evolution < %s | FileCheck %s --check-prefix=CHECK-ANALYSIS-2 | ||
|
||
define i32 @pr34538() local_unnamed_addr #0 { | ||
; CHECK-ANALYSIS-1: Loop %do.body: backedge-taken count is 10000 | ||
; CHECK-ANALYSIS-1: Loop %do.body: max backedge-taken count is 10000 | ||
; CHECK-ANALYSIS-1: Loop %do.body: Predicated backedge-taken count is 10000 | ||
entry: | ||
br label %do.body | ||
|
||
do.body: ; preds = %do.body, %entry | ||
%start.0 = phi i32 [ 0, %entry ], [ %inc.start.0, %do.body ] | ||
%cmp = icmp slt i32 %start.0, 10000 | ||
%inc = zext i1 %cmp to i32 | ||
%inc.start.0 = add nsw i32 %start.0, %inc | ||
br i1 %cmp, label %do.body, label %do.end | ||
|
||
do.end: ; preds = %do.body | ||
ret i32 0 | ||
} | ||
|
||
|
||
define i32 @foo() { | ||
entry: | ||
br label %do.body | ||
|
||
do.body: ; preds = %do.body, %entry | ||
%start.0 = phi i32 [ 0, %entry ], [ %inc.start.0, %do.body ] | ||
%cmp = icmp slt i32 %start.0, 10000 | ||
%select_ext = select i1 %cmp, i32 2 , i32 1 | ||
%inc.start.0 = add nsw i32 %start.0, %select_ext | ||
br i1 %cmp, label %do.body, label %do.end | ||
|
||
do.end: ; preds = %do.body | ||
ret i32 0 | ||
; CHECK-ANALYSIS-2: Loop %do.body: backedge-taken count is 5000 | ||
; CHECK-ANALYSIS-2: Loop %do.body: max backedge-taken count is 5000 | ||
; CHECK-ANALYSIS-2: Loop %do.body: Predicated backedge-taken count is 5000 | ||
} |