Skip to content

Commit 35b0b1a

Browse files
committed
[test] Prcommit tests for D108651
1 parent 433b2ea commit 35b0b1a

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
; RUN: opt < %s -analyze -enable-new-pm=0 -scalar-evolution -scalar-evolution-classify-expressions=0 | FileCheck %s
2+
; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 2>&1 | FileCheck %s
3+
4+
; A collection of tests that show we can use facts about an exit test to
5+
; infer tighter bounds on an IV, and thus refine an IV into an addrec. The
6+
; basic tactic being used is proving NW from exit structure and then
7+
; implying NUW/NSW. Once NSW/NUW is inferred, we can derive addrecs from
8+
; the zext/sext cases that we couldn't at initial SCEV construction.
9+
10+
@G = external global i8
11+
12+
; CHECK-LABEL: Determining loop execution counts for: @nw_implies_nuw
13+
; CHECK: Loop %for.body: Unpredictable backedge-taken count
14+
; CHECK: Loop %for.body: Unpredictable max backedge-taken count
15+
define void @nw_implies_nuw(i16 %n) mustprogress {
16+
entry:
17+
br label %for.body
18+
19+
for.body: ; preds = %entry, %for.body
20+
%iv = phi i8 [ %iv.next, %for.body ], [ 0, %entry ]
21+
%iv.next = add i8 %iv, 1
22+
%zext = zext i8 %iv to i16
23+
%cmp = icmp ult i16 %zext, %n
24+
br i1 %cmp, label %for.body, label %for.end
25+
26+
for.end: ; preds = %for.body, %entry
27+
ret void
28+
}
29+
30+
; CHECK-LABEL: Determining loop execution counts for: @nw_implies_nsw
31+
; CHECK: Loop %for.body: Unpredictable backedge-taken count
32+
; CHECK: Loop %for.body: Unpredictable max backedge-taken count
33+
define void @nw_implies_nsw(i16 %n) mustprogress {
34+
entry:
35+
br label %for.body
36+
37+
for.body: ; preds = %entry, %for.body
38+
%iv = phi i8 [ %iv.next, %for.body ], [ -128, %entry ]
39+
%iv.next = add i8 %iv, 1
40+
%zext = sext i8 %iv to i16
41+
%cmp = icmp slt i16 %zext, %n
42+
br i1 %cmp, label %for.body, label %for.end
43+
44+
for.end: ; preds = %for.body, %entry
45+
ret void
46+
}
47+
48+
49+
; CHECK-LABEL: Determining loop execution counts for: @actually_infinite
50+
; CHECK: Loop %for.body: Unpredictable backedge-taken count
51+
; CHECK: Loop %for.body: Unpredictable max backedge-taken count
52+
define void @actually_infinite() {
53+
entry:
54+
br label %for.body
55+
56+
for.body: ; preds = %entry, %for.body
57+
%iv = phi i8 [ %iv.next, %for.body ], [ 0, %entry ]
58+
store volatile i8 %iv, i8* @G
59+
%iv.next = add i8 %iv, 1
60+
%zext = zext i8 %iv to i16
61+
%cmp = icmp ult i16 %zext, 257
62+
br i1 %cmp, label %for.body, label %for.end
63+
64+
for.end: ; preds = %for.body, %entry
65+
ret void
66+
}
67+
68+
declare void @llvm.assume(i1)
69+

0 commit comments

Comments
 (0)