• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mtriple=thumbv7m-linux-gnu < %s | FileCheck %s --check-prefix=CHECK --check-prefix=T2
2; RUN: llc -mtriple=thumbv6m-linux-gnu < %s | FileCheck %s --check-prefix=CHECK --check-prefix=T1
3
4; CHECK-LABEL: single_bit:
5; CHECK: lsls r0, r0, #23
6; T2-NEXT: mov
7; T2-NEXT: it
8; T1-NEXT: bmi
9define i32 @single_bit(i32 %p) {
10  %a = and i32 %p, 256
11  %b = icmp eq i32 %a, 0
12  br i1 %b, label %true, label %false
13
14true:
15  ret i32 1
16
17false:
18  ret i32 2
19}
20
21; CHECK-LABEL: single_bit_multi_use:
22; CHECK: lsls r0, r0, #23
23; T2-NEXT: mov
24; T2-NEXT: it
25; T1-NEXT: bmi
26define i32 @single_bit_multi_use(i32 %p, i32* %z) {
27  store i32 %p, i32* %z
28  %a = and i32 %p, 256
29  %b = icmp eq i32 %a, 0
30  br i1 %b, label %true, label %false
31
32true:
33  ret i32 1
34
35false:
36  ret i32 2
37}
38
39; CHECK-LABEL: multi_bit_lsb_ubfx:
40; CHECK: lsls r0, r0, #24
41; T2-NEXT: mov
42; T2-NEXT: it
43; T1-NEXT: beq
44define i32 @multi_bit_lsb_ubfx(i32 %p) {
45  %a = and i32 %p, 255
46  %b = icmp eq i32 %a, 0
47  br i1 %b, label %true, label %false
48
49true:
50  ret i32 1
51
52false:
53  ret i32 2
54}
55
56; CHECK-LABEL: multi_bit_msb:
57; CHECK: lsrs r0, r0, #24
58; T2-NEXT: mov
59; T2-NEXT: it
60; T1-NEXT: beq
61define i32 @multi_bit_msb(i32 %p) {
62  %a = and i32 %p, 4278190080  ; 0xff000000
63  %b = icmp eq i32 %a, 0
64  br i1 %b, label %true, label %false
65
66true:
67  ret i32 1
68
69false:
70  ret i32 2
71}
72
73; CHECK-LABEL: multi_bit_nosb:
74; T1: lsls r0, r0, #8
75; T1-NEXT: lsrs r0, r0, #24
76; T2: tst.w
77; T2-NEXT: it
78; T1-NEXT: beq
79define i32 @multi_bit_nosb(i32 %p) {
80  %a = and i32 %p, 16711680 ; 0x00ff0000
81  %b = icmp eq i32 %a, 0
82  br i1 %b, label %true, label %false
83
84true:
85  ret i32 1
86
87false:
88  ret i32 2
89}
90
91; CHECK-LABEL: i16_cmpz:
92; T1:      movs    r2, #127
93; T1-NEXT: lsls    r2, r2, #9
94; T1-NEXT: ands    r2, r0
95; T1-NEXT: lsrs    r0, r2, #9
96; T2:      and     r0, r0, #65024
97; T2-NEXT: movs    r2, #0
98; T2-NEXT: cmp.w   r2, r0, lsr #9
99define void @i16_cmpz(i16 %x, void (i32)* %foo) {
100entry:
101  %cmp = icmp ult i16 %x, 512
102  br i1 %cmp, label %if.then, label %if.end
103
104if.then:                                          ; preds = %entry
105  tail call void %foo(i32 0) #1
106  br label %if.end
107
108if.end:                                           ; preds = %if.then, %entry
109  ret void
110}
111