1 ; RUN: llc -o - %s -mattr=+arith-cbz-fusion | FileCheck %s
2 ; RUN: llc -o - %s -mcpu=cyclone | FileCheck %s
4 target triple = "arm64-apple-ios"
6 declare void @foobar(i32 %v0, i32 %v1)
8 ; Make sure sub is scheduled in front of cbnz
9 ; CHECK-LABEL: test_sub_cbz:
10 ; CHECK: add w[[ADDRES:[0-9]+]], w1, #7
11 ; CHECK: sub w[[SUBRES:[0-9]+]], w0, #13
12 ; CHECK-NEXT: cbnz w[[SUBRES]], [[SKIPBLOCK:LBB[0-9_]+]]
13 ; CHECK: mov [[REGTY:[x,w]]]0, [[REGTY]][[ADDRES]]
14 ; CHECK: mov [[REGTY]]1, [[REGTY]][[SUBRES]]
16 ; CHECK: [[SKIPBLOCK]]:
17 ; CHECK: mov [[REGTY]]0, [[REGTY]][[SUBRES]]
18 ; CHECK: mov [[REGTY]]1, [[REGTY]][[ADDRES]]
20 define void @test_sub_cbz(i32 %a0, i32 %a1) {
22 ; except for the fusion opportunity the sub/add should be equal so the
23 ; scheduler would leave them in source order if it weren't for the scheduling
25 %cond = icmp eq i32 %v0, 0
27 br i1 %cond, label %if, label %exit
30 call void @foobar(i32 %v1, i32 %v0)
34 call void @foobar(i32 %v0, i32 %v1)