1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00
llvm-mirror/test/Analysis/ScalarEvolution/pr34538.ll
Jatin Bhateja b020a5ea70 [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

llvm-svn: 318050
2017-11-13 16:43:24 +00:00

40 lines
1.5 KiB
LLVM

; 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
}