Skip to content

Commit abbbf98

Browse files
committed
[TargetLowering][DAGCombine][MSP430] Shift Amount Threshold in DAGCombine (4) (Baseline tests)
Summary: Baseline tests before applying D70042 Reviewers: spatel, asl Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70083
1 parent 29f5d16 commit abbbf98

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

llvm/test/CodeGen/MSP430/shift-amount-threshold.ll

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,73 @@ entry:
147147
%cond = select i1 %cmp, i16 32, i16 0
148148
ret i16 %cond
149149
}
150+
151+
; Check the following conversion in TargetLowering::SimplifySetCC
152+
; (X & 8) != 0 --> (X & 8) >> 3
153+
define i16 @testSimplifySetCC_0_sh8(i16 %x) {
154+
; CHECK-LABEL: testSimplifySetCC_0_sh8:
155+
; CHECK: ; %bb.0: ; %entry
156+
; CHECK-NEXT: bit #256, r12
157+
; CHECK-NEXT: mov r2, r12
158+
; CHECK-NEXT: and #1, r12
159+
; CHECK-NEXT: ret
160+
entry:
161+
%and = and i16 %x, 256
162+
%cmp = icmp ne i16 %and, 0
163+
%conv = zext i1 %cmp to i16
164+
ret i16 %conv
165+
}
166+
167+
; Check the following conversion in TargetLowering::SimplifySetCC
168+
; (X & 8) == 8 --> (X & 8) >> 3
169+
define i16 @testSimplifySetCC_1_sh8(i16 %x) {
170+
; CHECK-LABEL: testSimplifySetCC_1_sh8:
171+
; CHECK: ; %bb.0: ; %entry
172+
; CHECK-NEXT: bit #256, r12
173+
; CHECK-NEXT: mov r2, r12
174+
; CHECK-NEXT: and #1, r12
175+
; CHECK-NEXT: ret
176+
entry:
177+
%and = and i16 %x, 256
178+
%cmp = icmp eq i16 %and, 256
179+
%conv = zext i1 %cmp to i16
180+
ret i16 %conv
181+
}
182+
183+
; Check the following conversion in DAGCombiner::foldSelectCCToShiftAnd
184+
; select_cc setlt X, 0, A, 0 -> "and (srl X, C2), A" iff A is a single-bit
185+
define i16 @testShiftAnd_1_sh8(i16 %x) {
186+
; CHECK-LABEL: testShiftAnd_1_sh8:
187+
; CHECK: ; %bb.0: ; %entry
188+
; CHECK-NEXT: mov r12, r13
189+
; CHECK-NEXT: mov #128, r12
190+
; CHECK-NEXT: tst r13
191+
; CHECK-NEXT: jl .LBB10_2
192+
; CHECK-NEXT: ; %bb.1: ; %entry
193+
; CHECK-NEXT: clr r12
194+
; CHECK-NEXT: .LBB10_2: ; %entry
195+
; CHECK-NEXT: ret
196+
entry:
197+
%cmp = icmp slt i16 %x, 0
198+
%cond = select i1 %cmp, i16 128, i16 0
199+
ret i16 %cond
200+
}
201+
202+
; Check the following conversion in DAGCombiner::foldSelectCCToShiftAnd
203+
; select_cc setlt X, 0, A, 0 -> "and (srl X, C2), A" iff A is a single-bit
204+
define i16 @testShiftAnd_1_sh9(i16 %x) {
205+
; CHECK-LABEL: testShiftAnd_1_sh9:
206+
; CHECK: ; %bb.0: ; %entry
207+
; CHECK-NEXT: mov r12, r13
208+
; CHECK-NEXT: mov #64, r12
209+
; CHECK-NEXT: tst r13
210+
; CHECK-NEXT: jl .LBB11_2
211+
; CHECK-NEXT: ; %bb.1: ; %entry
212+
; CHECK-NEXT: clr r12
213+
; CHECK-NEXT: .LBB11_2: ; %entry
214+
; CHECK-NEXT: ret
215+
entry:
216+
%cmp = icmp slt i16 %x, 0
217+
%cond = select i1 %cmp, i16 64, i16 0
218+
ret i16 %cond
219+
}

0 commit comments

Comments
 (0)