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 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
|
; RUN: llc < %s -O1 -mtriple=aarch64-eabi -aarch64-enable-cond-br-tune=false | FileCheck %s
declare void @t()
define void @test1(i32 %a) {
; CHECK-LABEL: @test1
entry:
%sub = add nsw i32 %a, -12
%cmp = icmp slt i32 %sub, 0
br i1 %cmp, label %if.then, label %if.end
; CHECK: sub [[CMP:w[0-9]+]], w0, #12
; CHECK: tbnz [[CMP]], #31
if.then:
call void @t()
br label %if.end
if.end:
ret void
}
define void @test2(i64 %a) {
; CHECK-LABEL: @test2
entry:
%sub = add nsw i64 %a, -12
%cmp = icmp slt i64 %sub, 0
br i1 %cmp, label %if.then, label %if.end
; CHECK: sub [[CMP:x[0-9]+]], x0, #12
; CHECK: tbnz [[CMP]], #63
if.then:
call void @t()
br label %if.end
if.end:
ret void
}
define void @test3(i32 %a) {
; CHECK-LABEL: @test3
entry:
%sub = add nsw i32 %a, -12
%cmp = icmp sgt i32 %sub, -1
br i1 %cmp, label %if.then, label %if.end
; CHECK: sub [[CMP:w[0-9]+]], w0, #12
; CHECK: tbnz [[CMP]], #31
if.then:
call void @t()
br label %if.end
if.end:
ret void
}
define void @test4(i64 %a) {
; CHECK-LABEL: @test4
entry:
%sub = add nsw i64 %a, -12
%cmp = icmp sgt i64 %sub, -1
br i1 %cmp, label %if.then, label %if.end
; CHECK: sub [[CMP:x[0-9]+]], x0, #12
; CHECK: tbnz [[CMP]], #63
if.then:
call void @t()
br label %if.end
if.end:
ret void
}
define void @test5(i32 %a) {
; CHECK-LABEL: @test5
entry:
%sub = add nsw i32 %a, -12
%cmp = icmp sge i32 %sub, 0
br i1 %cmp, label %if.then, label %if.end
; CHECK: sub [[CMP:w[0-9]+]], w0, #12
; CHECK: tbnz [[CMP]], #31
if.then:
call void @t()
br label %if.end
if.end:
ret void
}
define void @test6(i64 %a) {
; CHECK-LABEL: @test6
entry:
%sub = add nsw i64 %a, -12
%cmp = icmp sge i64 %sub, 0
br i1 %cmp, label %if.then, label %if.end
; CHECK: sub [[CMP:x[0-9]+]], x0, #12
; CHECK: tbnz [[CMP]], #63
if.then:
call void @t()
br label %if.end
if.end:
ret void
}
define void @test7(i32 %a) {
; CHECK-LABEL: @test7
entry:
%sub = sub nsw i32 %a, 12
%cmp = icmp slt i32 %sub, 0
br i1 %cmp, label %if.then, label %if.end
; CHECK: sub [[CMP:w[0-9]+]], w0, #12
; CHECK: tbnz [[CMP]], #31
if.then:
call void @t()
br label %if.end
if.end:
ret void
}
define void @test8(i64 %val1, i64 %val2, i64 %val3) {
; CHECK-LABEL: @test8
%and1 = and i64 %val1, %val2
%tst1 = icmp slt i64 %and1, 0
br i1 %tst1, label %if.then1, label %if.end
; CHECK: tst x0, x1
; CHECK-NEXT: b.ge
if.then1:
%and2 = and i64 %val2, %val3
%tst2 = icmp sge i64 %and2, 0
br i1 %tst2, label %if.then2, label %if.end
; CHECK: and [[CMP:x[0-9]+]], x1, x2
; CHECK-NOT: cmp
; CHECK: tbnz [[CMP]], #63
if.then2:
%shifted_op1 = shl i64 %val2, 63
%shifted_and1 = and i64 %val1, %shifted_op1
%tst3 = icmp slt i64 %shifted_and1, 0
br i1 %tst3, label %if.then3, label %if.end
; CHECK: tst x0, x1, lsl #63
; CHECK: b.lt
if.then3:
%shifted_op2 = shl i64 %val2, 62
%shifted_and2 = and i64 %val1, %shifted_op2
%tst4 = icmp sge i64 %shifted_and2, 0
br i1 %tst4, label %if.then4, label %if.end
; CHECK: tst x0, x1, lsl #62
; CHECK: b.lt
if.then4:
call void @t()
br label %if.end
if.end:
ret void
}
define void @test9(i64 %val1) {
; CHECK-LABEL: @test9
%tst = icmp slt i64 %val1, 0
br i1 %tst, label %if.then, label %if.end
; CHECK-NOT: cmp
; CHECK: tbnz x0, #63
if.then:
call void @t()
br label %if.end
if.end:
ret void
}
define void @test10(i64 %val1) {
; CHECK-LABEL: @test10
%tst = icmp slt i64 %val1, 0
br i1 %tst, label %if.then, label %if.end
; CHECK-NOT: cmp
; CHECK: tbnz x0, #63
if.then:
call void @t()
br label %if.end
if.end:
ret void
}
define void @test11(i64 %val1, i64* %ptr) {
; CHECK-LABEL: @test11
; CHECK: ldr [[CMP:x[0-9]+]], [x1]
; CHECK-NOT: cmp
; CHECK: tbnz [[CMP]], #63
%val = load i64, i64* %ptr
%tst = icmp slt i64 %val, 0
br i1 %tst, label %if.then, label %if.end
if.then:
call void @t()
br label %if.end
if.end:
ret void
}
define void @test12(i64 %val1) {
; CHECK-LABEL: @test12
%tst = icmp slt i64 %val1, 0
br i1 %tst, label %if.then, label %if.end
; CHECK-NOT: cmp
; CHECK: tbnz x0, #63
if.then:
call void @t()
br label %if.end
if.end:
ret void
}
define void @test13(i64 %val1, i64 %val2) {
; CHECK-LABEL: @test13
%or = or i64 %val1, %val2
%tst = icmp slt i64 %or, 0
br i1 %tst, label %if.then, label %if.end
; CHECK: orr [[CMP:x[0-9]+]], x0, x1
; CHECK-NOT: cmp
; CHECK: tbnz [[CMP]], #63
if.then:
call void @t()
br label %if.end
if.end:
ret void
}
define void @test14(i1 %cond) {
; CHECK-LABEL: @test14
br i1 %cond, label %if.end, label %if.then
; CHECK-NOT: and
; CHECK: tbnz w0, #0
if.then:
call void @t()
br label %if.end
if.end:
ret void
}
define void @test15(i1 %cond) {
; CHECK-LABEL: @test15
%cond1 = xor i1 %cond, -1
br i1 %cond1, label %if.then, label %if.end
; CHECK-NOT: movn
; CHECK: tbnz w0, #0
if.then:
call void @t()
br label %if.end
if.end:
ret void
}
define void @test16(i64 %in) {
; CHECK-LABEL: @test16
%shl = shl i64 %in, 3
%and = and i64 %shl, 32
%cond = icmp eq i64 %and, 0
br i1 %cond, label %then, label %end
; CHECK-NOT: lsl
; CHECK: tbnz w0, #2
then:
call void @t()
br label %end
end:
ret void
}
define void @test17(i64 %in) {
; CHECK-LABEL: @test17
%shr = ashr i64 %in, 3
%and = and i64 %shr, 1
%cond = icmp eq i64 %and, 0
br i1 %cond, label %then, label %end
; CHECK-NOT: lsr
; CHECK: tbnz w0, #3
then:
call void @t()
br label %end
end:
ret void
}
define void @test18(i32 %in) {
; CHECK-LABEL: @test18
%shr = ashr i32 %in, 2
%cond = icmp sge i32 %shr, 0
br i1 %cond, label %then, label %end
; CHECK-NOT: asr
; CHECK: tbnz w0, #31
then:
call void @t()
br label %end
end:
ret void
}
define void @test19(i64 %in) {
; CHECK-LABEL: @test19
%shl = lshr i64 %in, 3
%trunc = trunc i64 %shl to i32
%and = and i32 %trunc, 1
%cond = icmp eq i32 %and, 0
br i1 %cond, label %then, label %end
; CHECK-NOT: ubfx
; CHECK: tbnz w0, #3
then:
call void @t()
br label %end
end:
ret void
}
define void @test20(i32 %in) nounwind {
; CHECK-LABEL: test20:
; CHECK: // %bb.0:
; CHECK-NEXT: tbnz w0, #2, .LBB19_2
; CHECK-NEXT: // %bb.1: // %then
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-NEXT: bl t
; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-NEXT: .LBB19_2: // %end
; CHECK-NEXT: ret
%shl = shl i32 %in, 3
%zext = zext i32 %shl to i64
%and = and i64 %zext, 32
%cond = icmp eq i64 %and, 0
br i1 %cond, label %then, label %end
then:
call void @t()
br label %end
end:
ret void
}
|