1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -O0 -run-pass=aarch64-prelegalizer-combiner -global-isel -verify-machineinstrs %s -o - | FileCheck %s
4 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
5 target triple = "arm64-apple-ios5.0.0"
7 define i32 @foo(i32 %a, i32 %b) {
9 %cmp = icmp sgt i32 %a, 0
10 br i1 %cmp, label %if.then, label %if.end
13 %add = add nsw i32 %b, %a
14 %add1 = add nsw i32 %a, %b
18 %mul = mul nsw i32 %b, %b
19 %add2 = add nuw nsw i32 %mul, 2
23 %retval.0 = phi i32 [ %add1, %if.then ], [ %add2, %if.end ]
31 tracksRegLiveness: true
33 ; CHECK-LABEL: name: foo
35 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
36 ; CHECK: liveins: $w0, $w1
37 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
38 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
39 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
40 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
41 ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(sle), [[COPY]](s32), [[C]]
42 ; CHECK: G_BRCOND [[ICMP]](s1), %bb.2
43 ; CHECK: bb.1.if.then:
44 ; CHECK: successors: %bb.3(0x80000000)
45 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = nsw G_ADD [[COPY1]], [[COPY]]
46 ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = nsw G_ADD [[ADD]], [[COPY1]]
49 ; CHECK: successors: %bb.3(0x80000000)
50 ; CHECK: [[MUL:%[0-9]+]]:_(s32) = nsw G_MUL [[COPY1]], [[COPY1]]
51 ; CHECK: [[ADD2:%[0-9]+]]:_(s32) = nuw nsw G_ADD [[MUL]], [[C1]]
53 ; CHECK: [[PHI:%[0-9]+]]:_(s32) = G_PHI [[ADD1]](s32), %bb.1, [[ADD2]](s32), %bb.2
54 ; CHECK: $w0 = COPY [[PHI]](s32)
55 ; CHECK: RET_ReallyLR implicit $w0
61 %2:_(s32) = G_CONSTANT i32 0
62 %5:_(s32) = G_CONSTANT i32 2
63 %3:_(s1) = G_ICMP intpred(sgt), %0(s32), %2
64 G_BRCOND %3(s1), %bb.2
68 %7:_(s32) = nsw G_ADD %1, %0
69 %8:_(s32) = nsw G_ADD %7, %1
73 %4:_(s32) = nsw G_MUL %1, %1
74 %6:_(s32) = nuw nsw G_ADD %4, %5
77 %10:_(s32) = G_PHI %8(s32), %bb.2, %6(s32), %bb.3
79 RET_ReallyLR implicit $w0