shift-amount-threshold.ll
5.96 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
209
210
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=msp430-- < %s | FileCheck %s
; Check the following conversion in TargetLowering::SimplifySetCC
; (X & 8) != 0 --> (X & 8) >> 3
define i16 @testSimplifySetCC_0(i16 %x) {
; CHECK-LABEL: testSimplifySetCC_0:
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: bit #32, r12
; CHECK-NEXT: mov r2, r12
; CHECK-NEXT: and #1, r12
; CHECK-NEXT: ret
entry:
%and = and i16 %x, 32
%cmp = icmp ne i16 %and, 0
%conv = zext i1 %cmp to i16
ret i16 %conv
}
; Check the following conversion in TargetLowering::SimplifySetCC
; (X & 8) == 8 --> (X & 8) >> 3
define i16 @testSimplifySetCC_1(i16 %x) {
; CHECK-LABEL: testSimplifySetCC_1:
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: bit #32, r12
; CHECK-NEXT: mov r2, r12
; CHECK-NEXT: and #1, r12
; CHECK-NEXT: ret
entry:
%and = and i16 %x, 32
%cmp = icmp eq i16 %and, 32
%conv = zext i1 %cmp to i16
ret i16 %conv
}
; Check the following conversion in DAGCombiner::SimplifySelectCC
; (select_cc seteq (and x, y), 0, 0, A) -> (and (shr (shl x)) A)
define i16 @testSimplifySelectCC_0(i16 %x, i16 %a) {
; CHECK-LABEL: testSimplifySelectCC_0:
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: mov r12, r14
; CHECK-NEXT: clr r12
; CHECK-NEXT: bit #2048, r14
; CHECK-NEXT: jeq .LBB2_2
; CHECK-NEXT: ; %bb.1: ; %entry
; CHECK-NEXT: mov r13, r12
; CHECK-NEXT: .LBB2_2: ; %entry
; CHECK-NEXT: ret
entry:
%and = and i16 %x, 2048
%cmp = icmp eq i16 %and, 0
%cond = select i1 %cmp, i16 0, i16 %a
ret i16 %cond
}
; Check the following conversion in DAGCombiner foldExtendedSignBitTest
; sext i1 (setgt iN X, -1) --> sra (not X), (N - 1)
define i16 @testExtendSignBit_0(i16 %x) {
; CHECK-LABEL: testExtendSignBit_0:
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: mov r12, r13
; CHECK-NEXT: mov #-1, r12
; CHECK-NEXT: tst r13
; CHECK-NEXT: jge .LBB3_2
; CHECK-NEXT: ; %bb.1: ; %entry
; CHECK-NEXT: clr r12
; CHECK-NEXT: .LBB3_2: ; %entry
; CHECK-NEXT: ret
entry:
%cmp = icmp sgt i16 %x, -1
%cond = sext i1 %cmp to i16
ret i16 %cond
}
; Check the following conversion in DAGCombiner foldExtendedSignBitTest
; zext i1 (setgt iN X, -1) --> srl (not X), (N - 1)
define i16 @testExtendSignBit_1(i16 %x) {
; CHECK-LABEL: testExtendSignBit_1:
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: mov r12, r13
; CHECK-NEXT: mov #1, r12
; CHECK-NEXT: tst r13
; CHECK-NEXT: jge .LBB4_2
; CHECK-NEXT: ; %bb.1: ; %entry
; CHECK-NEXT: clr r12
; CHECK-NEXT: .LBB4_2: ; %entry
; CHECK-NEXT: ret
entry:
%cmp = icmp sgt i16 %x, -1
%cond = zext i1 %cmp to i16
ret i16 %cond
}
; Check the following conversion in DAGCombiner::foldSelectCCToShiftAnd
; select_cc setlt X, 0, A, 0 -> and (sra X, size(X)-1), A
define i16 @testShiftAnd_0(i16 %x, i16 %a) {
; CHECK-LABEL: testShiftAnd_0:
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: tst r12
; CHECK-NEXT: jl .LBB5_2
; CHECK-NEXT: ; %bb.1: ; %entry
; CHECK-NEXT: clr r13
; CHECK-NEXT: .LBB5_2: ; %entry
; CHECK-NEXT: mov r13, r12
; CHECK-NEXT: ret
entry:
%cmp = icmp slt i16 %x, 0
%cond = select i1 %cmp, i16 %a, i16 0
ret i16 %cond
}
; Check the following conversion in DAGCombiner::foldSelectCCToShiftAnd
; select_cc setlt X, 0, A, 0 -> "and (srl X, C2), A" iff A is a single-bit
define i16 @testShiftAnd_1(i16 %x) {
; CHECK-LABEL: testShiftAnd_1:
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: mov r12, r13
; CHECK-NEXT: mov #1, r12
; CHECK-NEXT: tst r13
; CHECK-NEXT: jl .LBB6_2
; CHECK-NEXT: ; %bb.1: ; %entry
; CHECK-NEXT: clr r12
; CHECK-NEXT: .LBB6_2: ; %entry
; CHECK-NEXT: add r12, r12
; CHECK-NEXT: ret
entry:
%cmp = icmp slt i16 %x, 0
%cond = select i1 %cmp, i16 2, i16 0
ret i16 %cond
}
; Check the following conversion in DAGCombiner::SimplifySelectCC
; select C, 16, 0 -> shl C, 4
define i16 @testSimplifySelectCC_1(i16 %a, i16 %b) {
; CHECK-LABEL: testSimplifySelectCC_1:
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: mov r12, r14
; CHECK-NEXT: mov #32, r12
; CHECK-NEXT: cmp r14, r13
; CHECK-NEXT: jl .LBB7_2
; CHECK-NEXT: ; %bb.1: ; %entry
; CHECK-NEXT: clr r12
; CHECK-NEXT: .LBB7_2: ; %entry
; CHECK-NEXT: ret
entry:
%cmp = icmp sgt i16 %a, %b
%cond = select i1 %cmp, i16 32, i16 0
ret i16 %cond
}
; Check the following conversion in TargetLowering::SimplifySetCC
; (X & 8) != 0 --> (X & 8) >> 3
define i16 @testSimplifySetCC_0_sh8(i16 %x) {
; CHECK-LABEL: testSimplifySetCC_0_sh8:
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: and #256, r12
; CHECK-NEXT: swpb r12
; CHECK-NEXT: ret
entry:
%and = and i16 %x, 256
%cmp = icmp ne i16 %and, 0
%conv = zext i1 %cmp to i16
ret i16 %conv
}
; Check the following conversion in TargetLowering::SimplifySetCC
; (X & 8) == 8 --> (X & 8) >> 3
define i16 @testSimplifySetCC_1_sh8(i16 %x) {
; CHECK-LABEL: testSimplifySetCC_1_sh8:
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: and #256, r12
; CHECK-NEXT: swpb r12
; CHECK-NEXT: ret
entry:
%and = and i16 %x, 256
%cmp = icmp eq i16 %and, 256
%conv = zext i1 %cmp to i16
ret i16 %conv
}
; Check the following conversion in DAGCombiner::foldSelectCCToShiftAnd
; select_cc setlt X, 0, A, 0 -> "and (srl X, C2), A" iff A is a single-bit
define i16 @testShiftAnd_1_sh8(i16 %x) {
; CHECK-LABEL: testShiftAnd_1_sh8:
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: swpb r12
; CHECK-NEXT: and #128, r12
; CHECK-NEXT: ret
entry:
%cmp = icmp slt i16 %x, 0
%cond = select i1 %cmp, i16 128, i16 0
ret i16 %cond
}
; Check the following conversion in DAGCombiner::foldSelectCCToShiftAnd
; select_cc setlt X, 0, A, 0 -> "and (srl X, C2), A" iff A is a single-bit
define i16 @testShiftAnd_1_sh9(i16 %x) {
; CHECK-LABEL: testShiftAnd_1_sh9:
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: swpb r12
; CHECK-NEXT: mov.b r12, r12
; CHECK-NEXT: clrc
; CHECK-NEXT: rrc r12
; CHECK-NEXT: and #64, r12
; CHECK-NEXT: ret
entry:
%cmp = icmp slt i16 %x, 0
%cond = select i1 %cmp, i16 64, i16 0
ret i16 %cond
}