cmp-and-fold.ll
4.63 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=thumbv6-eabi %s -o - | FileCheck %s
define void @test1(i32 %x, void ()* %f) {
; CHECK-LABEL: test1:
; CHECK: @ %bb.0: @ %entry
; CHECK-NEXT: .save {r7, lr}
; CHECK-NEXT: push {r7, lr}
; CHECK-NEXT: lsls r0, r0, #2
; CHECK-NEXT: cmp r0, #68
; CHECK-NEXT: beq .LBB0_2
; CHECK-NEXT: @ %bb.1: @ %if.then
; CHECK-NEXT: blx r1
; CHECK-NEXT: .LBB0_2: @ %if.end
; CHECK-NEXT: pop {r7, pc}
entry:
%a = and i32 %x, 1073741823
%cmp = icmp eq i32 %a, 17
br i1 %cmp, label %if.end, label %if.then
if.then:
tail call void %f()
br label %if.end
if.end:
ret void
}
define void @test2(i32 %x, void ()* %f) {
; CHECK-LABEL: test2:
; CHECK: @ %bb.0: @ %entry
; CHECK-NEXT: .save {r7, lr}
; CHECK-NEXT: push {r7, lr}
; CHECK-NEXT: lsls r0, r0, #8
; CHECK-NEXT: bhi .LBB1_2
; CHECK-NEXT: @ %bb.1: @ %if.then
; CHECK-NEXT: blx r1
; CHECK-NEXT: .LBB1_2: @ %if.end
; CHECK-NEXT: pop {r7, pc}
entry:
%a = shl i32 %x, 7
%cmp = icmp ugt i32 %a, 2147483648
br i1 %cmp, label %if.end, label %if.then
if.then:
tail call void %f()
br label %if.end
if.end:
ret void
}
define void @test3(i32 %x, void ()* %f) {
; CHECK-LABEL: test3:
; CHECK: @ %bb.0: @ %entry
; CHECK-NEXT: .save {r7, lr}
; CHECK-NEXT: push {r7, lr}
; CHECK-NEXT: lsls r0, r0, #3
; CHECK-NEXT: bhi .LBB2_2
; CHECK-NEXT: @ %bb.1: @ %if.then
; CHECK-NEXT: blx r1
; CHECK-NEXT: .LBB2_2: @ %if.end
; CHECK-NEXT: pop {r7, pc}
entry:
%a = and i32 %x, 1073741823
%cmp = icmp ugt i32 %a, 536870912
br i1 %cmp, label %if.end, label %if.then
if.then:
tail call void %f()
br label %if.end
if.end:
ret void
}
define void @test4(i32 %x, void ()* %f) {
; CHECK-LABEL: test4:
; CHECK: @ %bb.0: @ %entry
; CHECK-NEXT: .save {r7, lr}
; CHECK-NEXT: push {r7, lr}
; CHECK-NEXT: uxtb r0, r0
; CHECK-NEXT: cmp r0, #17
; CHECK-NEXT: beq .LBB3_2
; CHECK-NEXT: @ %bb.1: @ %if.then
; CHECK-NEXT: blx r1
; CHECK-NEXT: .LBB3_2: @ %if.end
; CHECK-NEXT: pop {r7, pc}
entry:
%a = and i32 %x, 255
%cmp = icmp eq i32 %a, 17
br i1 %cmp, label %if.end, label %if.then
if.then:
tail call void %f()
br label %if.end
if.end:
ret void
}
define void @test5(i32 %x, void ()* %f) {
; CHECK-LABEL: test5:
; CHECK: @ %bb.0: @ %entry
; CHECK-NEXT: .save {r7, lr}
; CHECK-NEXT: push {r7, lr}
; CHECK-NEXT: uxth r0, r0
; CHECK-NEXT: cmp r0, #17
; CHECK-NEXT: beq .LBB4_2
; CHECK-NEXT: @ %bb.1: @ %if.then
; CHECK-NEXT: blx r1
; CHECK-NEXT: .LBB4_2: @ %if.end
; CHECK-NEXT: pop {r7, pc}
entry:
%a = and i32 %x, 65535
%cmp = icmp eq i32 %a, 17
br i1 %cmp, label %if.end, label %if.then
if.then:
tail call void %f()
br label %if.end
if.end:
ret void
}
define void @test6(i32 %x, void ()* %f) {
; CHECK-LABEL: test6:
; CHECK: @ %bb.0: @ %entry
; CHECK-NEXT: .save {r7, lr}
; CHECK-NEXT: push {r7, lr}
; CHECK-NEXT: movs r2, #32
; CHECK-NEXT: ands r2, r0
; CHECK-NEXT: cmp r2, #17
; CHECK-NEXT: beq .LBB5_2
; CHECK-NEXT: @ %bb.1: @ %if.then
; CHECK-NEXT: blx r1
; CHECK-NEXT: .LBB5_2: @ %if.end
; CHECK-NEXT: pop {r7, pc}
entry:
%a = and i32 %x, 32
%cmp = icmp eq i32 %a, 17
br i1 %cmp, label %if.end, label %if.then
if.then:
tail call void %f()
br label %if.end
if.end:
ret void
}
define void @test7(i32 %x, void ()* %f) {
; CHECK-LABEL: test7:
; CHECK: @ %bb.0: @ %entry
; CHECK-NEXT: .save {r7, lr}
; CHECK-NEXT: push {r7, lr}
; CHECK-NEXT: ldr r2, .LCPI6_0
; CHECK-NEXT: ands r2, r0
; CHECK-NEXT: cmp r2, #17
; CHECK-NEXT: beq .LBB6_2
; CHECK-NEXT: @ %bb.1: @ %if.then
; CHECK-NEXT: blx r1
; CHECK-NEXT: .LBB6_2: @ %if.end
; CHECK-NEXT: pop {r7, pc}
; CHECK-NEXT: .p2align 2
; CHECK-NEXT: @ %bb.3:
; CHECK-NEXT: .LCPI6_0:
; CHECK-NEXT: .long 1023 @ 0x3ff
entry:
%a = and i32 %x, 1023
%cmp = icmp eq i32 %a, 17
br i1 %cmp, label %if.end, label %if.then
if.then:
tail call void %f()
br label %if.end
if.end:
ret void
}
define void @test8(i32 %x, void ()* %f) {
; CHECK-LABEL: test8:
; CHECK: @ %bb.0: @ %entry
; CHECK-NEXT: .save {r7, lr}
; CHECK-NEXT: push {r7, lr}
; CHECK-NEXT: movs r2, #129
; CHECK-NEXT: lsls r2, r2, #23
; CHECK-NEXT: lsls r0, r0, #22
; CHECK-NEXT: cmp r0, r2
; CHECK-NEXT: beq .LBB7_2
; CHECK-NEXT: @ %bb.1: @ %if.then
; CHECK-NEXT: blx r1
; CHECK-NEXT: .LBB7_2: @ %if.end
; CHECK-NEXT: pop {r7, pc}
entry:
%a = and i32 %x, 1023
%cmp = icmp eq i32 %a, 258
br i1 %cmp, label %if.end, label %if.then
if.then:
tail call void %f()
br label %if.end
if.end:
ret void
}