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
131
132
133
134
135
136
137
138
139
140
141
142
|
; RUN: opt < %s -indvars -S -enable-iv-rewrite=false "-default-data-layout=e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" | FileCheck %s
; RUN: opt < %s -indvars -S -enable-iv-rewrite=true "-default-data-layout=e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" | FileCheck %s
; RUN: opt < %s -indvars -S -enable-iv-rewrite=false "-default-data-layout=e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32" | FileCheck %s
; RUN: opt < %s -indvars -S -enable-iv-rewrite=true "-default-data-layout=e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32" | FileCheck %s
;
; PR11279: Assertion !IVLimit->getType()->isPointerTy()
;
; Test LinearFunctionTestReplace of a pointer-type loop counter. Note
; that BECount may or may not be a pointer type. A pointer type
; BECount doesn't really make sense, but that's what falls out of
; SCEV. Since it's an i8*, it has unit stride so we never adjust the
; SCEV expression in a way that would convert it to an integer type.
; CHECK: @testnullptrptr
; CHECK: loop:
; CHECK: icmp ne
define i8 @testnullptrptr(i8* %buf, i8* %end) nounwind {
br label %loopguard
loopguard:
%guard = icmp ult i8* null, %end
br i1 %guard, label %preheader, label %exit
preheader:
br label %loop
loop:
%p.01.us.us = phi i8* [ null, %preheader ], [ %gep, %loop ]
%s = phi i8 [0, %preheader], [%snext, %loop]
%gep = getelementptr inbounds i8* %p.01.us.us, i64 1
%snext = load i8* %gep
%cmp = icmp ult i8* %gep, %end
br i1 %cmp, label %loop, label %exit
exit:
ret i8 %snext
}
; CHECK: @testptrptr
; CHECK: loop:
; CHECK: icmp ne
define i8 @testptrptr(i8* %buf, i8* %end) nounwind {
br label %loopguard
loopguard:
%guard = icmp ult i8* %buf, %end
br i1 %guard, label %preheader, label %exit
preheader:
br label %loop
loop:
%p.01.us.us = phi i8* [ %buf, %preheader ], [ %gep, %loop ]
%s = phi i8 [0, %preheader], [%snext, %loop]
%gep = getelementptr inbounds i8* %p.01.us.us, i64 1
%snext = load i8* %gep
%cmp = icmp ult i8* %gep, %end
br i1 %cmp, label %loop, label %exit
exit:
ret i8 %snext
}
; CHECK: @testnullptrint
; CHECK: loop:
; CHECK: icmp ne
define i8 @testnullptrint(i8* %buf, i8* %end) nounwind {
br label %loopguard
loopguard:
%bi = ptrtoint i8* %buf to i32
%ei = ptrtoint i8* %end to i32
%cnt = sub i32 %ei, %bi
%guard = icmp ult i32 0, %cnt
br i1 %guard, label %preheader, label %exit
preheader:
br label %loop
loop:
%p.01.us.us = phi i8* [ null, %preheader ], [ %gep, %loop ]
%iv = phi i32 [ 0, %preheader ], [ %ivnext, %loop ]
%s = phi i8 [0, %preheader], [%snext, %loop]
%gep = getelementptr inbounds i8* %p.01.us.us, i64 1
%snext = load i8* %gep
%ivnext = add i32 %iv, 1
%cmp = icmp ult i32 %ivnext, %cnt
br i1 %cmp, label %loop, label %exit
exit:
ret i8 %snext
}
; CHECK: @testptrint
; CHECK: loop:
; CHECK: icmp ne
define i8 @testptrint(i8* %buf, i8* %end) nounwind {
br label %loopguard
loopguard:
%bi = ptrtoint i8* %buf to i32
%ei = ptrtoint i8* %end to i32
%cnt = sub i32 %ei, %bi
%guard = icmp ult i32 %bi, %cnt
br i1 %guard, label %preheader, label %exit
preheader:
br label %loop
loop:
%p.01.us.us = phi i8* [ %buf, %preheader ], [ %gep, %loop ]
%iv = phi i32 [ %bi, %preheader ], [ %ivnext, %loop ]
%s = phi i8 [0, %preheader], [%snext, %loop]
%gep = getelementptr inbounds i8* %p.01.us.us, i64 1
%snext = load i8* %gep
%ivnext = add i32 %iv, 1
%cmp = icmp ult i32 %ivnext, %cnt
br i1 %cmp, label %loop, label %exit
exit:
ret i8 %snext
}
; IV and BECount have two different pointer types here.
define void @testnullptr([512 x i8]* %base) nounwind {
entry:
%add.ptr1603 = getelementptr [512 x i8]* %base, i64 0, i64 512
br label %preheader
preheader:
%cmp1604192 = icmp ult i8* undef, %add.ptr1603
br i1 %cmp1604192, label %for.body, label %for.end1609
for.body:
%r.17193 = phi i8* [ %incdec.ptr1608, %for.body ], [ null, %preheader ]
%incdec.ptr1608 = getelementptr i8* %r.17193, i64 1
%cmp1604 = icmp ult i8* %incdec.ptr1608, %add.ptr1603
br i1 %cmp1604, label %for.body, label %for.end1609
for.end1609:
unreachable
}
|