1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
| ; RUN: opt < %s -indvars -S | FileCheck %s
define void @test0(i32* %a) {
; CHECK-LABEL: @test0(
entry:
br label %for.body
for.body: ; preds = %entry, %for.body
%i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
%div = sdiv i32 %i.01, 2
; CHECK-NOT: sdiv
; CHECK: udiv
%idxprom = sext i32 %div to i64
%arrayidx = getelementptr inbounds i32, i32* %a, i64 %idxprom
store i32 %i.01, i32* %arrayidx, align 4
%inc = add nsw i32 %i.01, 1
%cmp = icmp slt i32 %inc, 64
br i1 %cmp, label %for.body, label %for.end
for.end: ; preds = %for.body
ret void
}
define void @test1(i32* %a) {
; CHECK-LABEL: @test1(
entry:
br label %for.body
for.body: ; preds = %entry, %for.body
%i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
%div = sdiv exact i32 %i.01, 2
; CHECK-NOT: sdiv
; CHECK: udiv exact
%idxprom = sext i32 %div to i64
%arrayidx = getelementptr inbounds i32, i32* %a, i64 %idxprom
store i32 %i.01, i32* %arrayidx, align 4
%inc = add nsw i32 %i.01, 1
%cmp = icmp slt i32 %inc, 64
br i1 %cmp, label %for.body, label %for.end
for.end: ; preds = %for.body
ret void
}
define void @test2(i32* %a, i32 %d) {
; CHECK-LABEL: @test2(
entry:
br label %for.body
for.body: ; preds = %entry, %for.body
%i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
%mul = mul nsw i32 %i.01, 64
%div = sdiv i32 %mul, %d
; CHECK-NOT: udiv
%idxprom = sext i32 %div to i64
%arrayidx = getelementptr inbounds i32, i32* %a, i64 %idxprom
store i32 %i.01, i32* %arrayidx, align 4
%inc = add nsw i32 %i.01, 1
%cmp = icmp slt i32 %inc, 64
br i1 %cmp, label %for.body, label %for.end
for.end: ; preds = %for.body
ret void
}
define void @test3(i32* %a) {
; CHECK-LABEL: @test3(
entry:
br label %for.body
for.body: ; preds = %entry, %for.body
%i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
%div = sdiv i32 2048, %i.01
; CHECK: udiv
; CHECK-NOT: sdiv
%idxprom = sext i32 %div to i64
%arrayidx = getelementptr inbounds i32, i32* %a, i64 %idxprom
store i32 %i.01, i32* %arrayidx, align 4
%inc = add nsw i32 %i.01, 1
%cmp = icmp slt i32 %inc, 64
br i1 %cmp, label %for.body, label %for.end
for.end: ; preds = %for.body
ret void
}
define void @test4(i32* %a) {
; CHECK-LABEL: @test4(
entry:
br label %for.body
for.body: ; preds = %entry, %for.body
%i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
%mul = mul nsw i32 %i.01, 64
%div = sdiv i32 %mul, 8
; CHECK: udiv
; CHECK-NOT: sdiv
%idxprom = sext i32 %div to i64
%arrayidx = getelementptr inbounds i32, i32* %a, i64 %idxprom
store i32 %i.01, i32* %arrayidx, align 4
%inc = add nsw i32 %i.01, 1
%cmp = icmp slt i32 %inc, 64
br i1 %cmp, label %for.body, label %for.end
for.end: ; preds = %for.body
ret void
}
define void @test5(i32* %a) {
; CHECK-LABEL: @test5(
entry:
br label %for.body
for.body: ; preds = %entry, %for.body
%i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
%mul = mul nsw i32 %i.01, 64
%div = sdiv i32 %mul, 6
; CHECK: udiv
; CHECK-NOT: sdiv
%idxprom = sext i32 %div to i64
%arrayidx = getelementptr inbounds i32, i32* %a, i64 %idxprom
store i32 %i.01, i32* %arrayidx, align 4
%inc = add nsw i32 %i.01, 1
%cmp = icmp slt i32 %inc, 64
br i1 %cmp, label %for.body, label %for.end
for.end: ; preds = %for.body
ret void
}
|