1 ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 ; RUN: llc -mtriple aarch64 -aarch64-enable-atomic-cfg-tidy=0 -stop-after=irtranslator -global-isel -verify-machineinstrs %s -o - 2>&1 | FileCheck %s
4 define i32 @test_bittest(i16 %p) {
5 ; CHECK-LABEL: name: test_bittest
6 ; CHECK: bb.1 (%ir-block.0):
7 ; CHECK: successors: %bb.4(0x1b6db6db), %bb.5(0x64924925)
9 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
10 ; CHECK: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32)
11 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 114
12 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 42
13 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
14 ; CHECK: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[TRUNC]](s16)
15 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
16 ; CHECK: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[ZEXT]], [[C3]]
17 ; CHECK: [[ZEXT1:%[0-9]+]]:_(s64) = G_ZEXT [[SUB]](s32)
18 ; CHECK: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 59
19 ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ugt), [[SUB]](s32), [[C4]]
20 ; CHECK: G_BRCOND [[ICMP]](s1), %bb.4
22 ; CHECK: bb.4 (%ir-block.0):
23 ; CHECK: successors: %bb.3(0x40000000), %bb.2(0x40000000)
24 ; CHECK: [[ICMP1:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[ZEXT]](s32), [[C]]
25 ; CHECK: G_BRCOND [[ICMP1]](s1), %bb.3
27 ; CHECK: bb.5 (%ir-block.0):
28 ; CHECK: successors: %bb.3(0x745d1746), %bb.4(0x0ba2e8ba)
29 ; CHECK: [[C5:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
30 ; CHECK: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[C5]], [[ZEXT1]](s64)
31 ; CHECK: [[C6:%[0-9]+]]:_(s64) = G_CONSTANT i64 866239240827043840
32 ; CHECK: [[AND:%[0-9]+]]:_(s64) = G_AND [[SHL]], [[C6]]
33 ; CHECK: [[C7:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
34 ; CHECK: [[ICMP2:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[AND]](s64), [[C7]]
35 ; CHECK: G_BRCOND [[ICMP2]](s1), %bb.3
37 ; CHECK: bb.2.sw.epilog:
38 ; CHECK: $w0 = COPY [[C2]](s32)
39 ; CHECK: RET_ReallyLR implicit $w0
41 ; CHECK: $w0 = COPY [[C1]](s32)
42 ; CHECK: RET_ReallyLR implicit $w0
43 switch i16 %p, label %sw.epilog [
59 declare void @callee()
61 define void @test_bittest_2_bt(i32 %p) {
62 ; CHECK-LABEL: name: test_bittest_2_bt
64 ; CHECK: successors: %bb.5(0x345d1746), %bb.6(0x4ba2e8ba)
66 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
67 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 176
68 ; CHECK: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY]], [[C]]
69 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 15
70 ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ugt), [[SUB]](s32), [[C1]]
71 ; CHECK: G_BRCOND [[ICMP]](s1), %bb.5
74 ; CHECK: successors: %bb.4(0x0ccccccd), %bb.7(0x73333333)
75 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
76 ; CHECK: [[SUB1:%[0-9]+]]:_(s32) = G_SUB [[COPY]], [[C2]]
77 ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[SUB1]](s32)
78 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 38
79 ; CHECK: [[ICMP1:%[0-9]+]]:_(s1) = G_ICMP intpred(ugt), [[SUB1]](s32), [[C3]]
80 ; CHECK: G_BRCOND [[ICMP1]](s1), %bb.4
83 ; CHECK: successors: %bb.2(0x76276276), %bb.5(0x09d89d8a)
84 ; CHECK: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
85 ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[C4]], [[SUB]](s32)
86 ; CHECK: [[C5:%[0-9]+]]:_(s32) = G_CONSTANT i32 57351
87 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[SHL]], [[C5]]
88 ; CHECK: [[C6:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
89 ; CHECK: [[ICMP2:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[AND]](s32), [[C6]]
90 ; CHECK: G_BRCOND [[ICMP2]](s1), %bb.2
93 ; CHECK: successors: %bb.3(0x71c71c72), %bb.4(0x0e38e38e)
94 ; CHECK: [[C7:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
95 ; CHECK: [[SHL1:%[0-9]+]]:_(s64) = G_SHL [[C7]], [[ZEXT]](s64)
96 ; CHECK: [[C8:%[0-9]+]]:_(s64) = G_CONSTANT i64 365072220160
97 ; CHECK: [[AND1:%[0-9]+]]:_(s64) = G_AND [[SHL1]], [[C8]]
98 ; CHECK: [[C9:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
99 ; CHECK: [[ICMP3:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[AND1]](s64), [[C9]]
100 ; CHECK: G_BRCOND [[ICMP3]](s1), %bb.3
102 ; CHECK: bb.2.sw.bb37:
103 ; CHECK: TCRETURNdi @callee, 0, csr_aarch64_aapcs, implicit $sp
104 ; CHECK: bb.3.sw.bb55:
105 ; CHECK: TCRETURNdi @callee, 0, csr_aarch64_aapcs, implicit $sp
106 ; CHECK: bb.4.sw.default:
107 ; CHECK: RET_ReallyLR
109 switch i32 %p, label %sw.default [
110 i32 32, label %sw.bb55
111 i32 34, label %sw.bb55
112 i32 36, label %sw.bb55
113 i32 191, label %sw.bb37
114 i32 190, label %sw.bb37
115 i32 189, label %sw.bb37
116 i32 178, label %sw.bb37
117 i32 177, label %sw.bb37
118 i32 176, label %sw.bb37
119 i32 38, label %sw.bb55
122 sw.bb37: ; preds = %entry, %entry, %entry, %entry, %entry, %entry
123 tail call void @callee()
126 sw.bb55: ; preds = %entry, %entry, %entry, %entry
127 tail call void @callee()
130 sw.default: ; preds = %entry
134 define i32 @test_bittest_single_bt_only_with_fallthrough(i16 %p) {
135 ; CHECK-LABEL: name: test_bittest_single_bt_only_with_fallthrough
136 ; CHECK: bb.1 (%ir-block.0):
137 ; CHECK: successors: %bb.2(0x0aaaaaab), %bb.4(0x75555555)
138 ; CHECK: liveins: $w0
139 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
140 ; CHECK: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32)
141 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 42
142 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
143 ; CHECK: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[TRUNC]](s16)
144 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
145 ; CHECK: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[ZEXT]], [[C2]]
146 ; CHECK: [[ZEXT1:%[0-9]+]]:_(s64) = G_ZEXT [[SUB]](s32)
147 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 59
148 ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ugt), [[SUB]](s32), [[C3]]
149 ; CHECK: G_BRCOND [[ICMP]](s1), %bb.2
150 ; CHECK: bb.4 (%ir-block.0):
151 ; CHECK: successors: %bb.3(0x745d1746), %bb.2(0x0ba2e8ba)
152 ; CHECK: [[C4:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
153 ; CHECK: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[C4]], [[ZEXT1]](s64)
154 ; CHECK: [[C5:%[0-9]+]]:_(s64) = G_CONSTANT i64 866239240827043840
155 ; CHECK: [[AND:%[0-9]+]]:_(s64) = G_AND [[SHL]], [[C5]]
156 ; CHECK: [[C6:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
157 ; CHECK: [[ICMP1:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[AND]](s64), [[C6]]
158 ; CHECK: G_BRCOND [[ICMP1]](s1), %bb.3
159 ; CHECK: bb.2.sw.epilog:
160 ; CHECK: $w0 = COPY [[C1]](s32)
161 ; CHECK: RET_ReallyLR implicit $w0
163 ; CHECK: $w0 = COPY [[C]](s32)
164 ; CHECK: RET_ReallyLR implicit $w0
165 switch i16 %p, label %sw.epilog [
179 define void @bit_test_block_incomplete_phi() {
180 ; CHECK-LABEL: name: bit_test_block_incomplete_phi
182 ; CHECK: successors: %bb.5(0x80000000)
183 ; CHECK: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
184 ; CHECK: [[DEF1:%[0-9]+]]:_(p0) = G_IMPLICIT_DEF
185 ; CHECK: [[C:%[0-9]+]]:_(s1) = G_CONSTANT i1 false
186 ; CHECK: [[C1:%[0-9]+]]:_(s1) = G_CONSTANT i1 true
187 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
188 ; CHECK: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[DEF]], [[C2]]
190 ; CHECK: successors: %bb.3(0x51745d17), %bb.4(0x2e8ba2e9)
191 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
192 ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[C3]], [[SUB]](s32)
193 ; CHECK: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 491
194 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[SHL]], [[C4]]
195 ; CHECK: [[C5:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
196 ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[AND]](s32), [[C5]]
197 ; CHECK: G_BRCOND [[ICMP]](s1), %bb.3
201 ; CHECK: bb.2.sw.epilog.i:
203 ; CHECK: bb.3.if.end:
204 ; CHECK: successors: %bb.4(0x80000000)
205 ; CHECK: [[LOAD:%[0-9]+]]:_(p0) = G_LOAD [[DEF1]](p0) :: (load (p0) from `i8** undef`)
206 ; CHECK: bb.4.return:
207 ; CHECK: [[PHI:%[0-9]+]]:_(s1) = G_PHI [[C]](s1), %bb.3, [[C1]](s1), %bb.5
208 ; CHECK: RET_ReallyLR
210 switch i32 undef, label %sw.epilog.i [
213 i32 10, label %return
224 sw.epilog.i: ; preds = %entry
227 if.end: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry
228 %0 = load i8*, i8** undef, align 8
231 return: ; preds = %if.end, %entry, %entry, %entry, %entry
232 %retval.0 = phi i1 [ false, %if.end ], [ true, %entry ], [ true, %entry ], [ true, %entry ], [ true, %entry ]