1 ; RUN: llc -O0 -fast-isel -fast-isel-abort=1 -verify-machineinstrs -mtriple=arm64-apple-darwin < %s | FileCheck %s
3 define void @t0(i32 %a) nounwind {
6 ; CHECK: str {{w[0-9]+}}, [sp, #12]
7 ; CHECK-NEXT: ldr [[REGISTER:w[0-9]+]], [sp, #12]
8 ; CHECK-NEXT: str [[REGISTER]], [sp, #12]
10 %a.addr = alloca i32, align 4
11 store i32 %a, ptr %a.addr
12 %tmp = load i32, ptr %a.addr
13 store i32 %tmp, ptr %a.addr
17 define void @t1(i64 %a) nounwind {
19 ; CHECK: str {{x[0-9]+}}, [sp, #8]
20 ; CHECK-NEXT: ldr [[REGISTER:x[0-9]+]], [sp, #8]
21 ; CHECK-NEXT: str [[REGISTER]], [sp, #8]
23 %a.addr = alloca i64, align 4
24 store i64 %a, ptr %a.addr
25 %tmp = load i64, ptr %a.addr
26 store i64 %tmp, ptr %a.addr
30 define zeroext i1 @i1(i1 %a) nounwind {
33 ; CHECK: and [[REG:w[0-9]+]], w0, #0x1
34 ; CHECK: strb [[REG]], [sp, #15]
35 ; CHECK: ldrb [[REG1:w[0-9]+]], [sp, #15]
36 ; CHECK: and [[REG2:w[0-9]+]], [[REG1]], #0x1
37 ; CHECK: and w0, [[REG2]], #0x1
38 ; CHECK: add sp, sp, #16
40 %a.addr = alloca i1, align 1
41 store i1 %a, ptr %a.addr, align 1
42 %0 = load i1, ptr %a.addr, align 1
46 define i32 @t2(ptr %ptr) nounwind {
49 ; CHECK: ldur w0, [x0, #-4]
51 %0 = getelementptr i32, ptr %ptr, i32 -1
52 %1 = load i32, ptr %0, align 4
56 define i32 @t3(ptr %ptr) nounwind {
59 ; CHECK: ldur w0, [x0, #-256]
61 %0 = getelementptr i32, ptr %ptr, i32 -64
62 %1 = load i32, ptr %0, align 4
66 define void @t4(ptr %ptr) nounwind {
69 ; CHECK: stur wzr, [x0, #-4]
71 %0 = getelementptr i32, ptr %ptr, i32 -1
72 store i32 0, ptr %0, align 4
76 define void @t5(ptr %ptr) nounwind {
79 ; CHECK: stur wzr, [x0, #-256]
81 %0 = getelementptr i32, ptr %ptr, i32 -64
82 store i32 0, ptr %0, align 4
86 define void @t6() nounwind {
89 tail call void @llvm.trap()
93 declare void @llvm.trap() nounwind
95 define void @ands(ptr %addr) {
96 ; FIXME: 'select i1 undef' makes this unreliable (ub?).
97 ; COM: CHECK-LABEL: ands:
98 ; COM: CHECK: tst [[COND:w[0-9]+]], #0x1
99 ; COM: CHECK-NEXT: mov w{{[0-9]+}}, #2
100 ; COM: CHECK-NEXT: mov w{{[0-9]+}}, #1
101 ; COM: CHECK-NEXT: csel [[COND]],
103 %cond91 = select i1 undef, i32 1, i32 2
104 store i32 %cond91, ptr %addr, align 4
108 define i64 @mul_umul(i64 %arg) {
109 ; CHECK-LABEL: mul_umul:
110 ; CHECK: mul x{{[0-9]+}}, [[ARG1:x[0-9]+]], [[ARG2:x[0-9]+]]
111 ; CHECK-NEXT: umulh x{{[0-9]+}}, [[ARG1]], [[ARG2]]
113 %sub.ptr.div = sdiv exact i64 %arg, 8
114 %tmp = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %sub.ptr.div, i64 8)
115 %tmp1 = extractvalue { i64, i1 } %tmp, 0
119 declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64)
121 define void @logicalReg() {
122 ; Make sure we generate a logical reg = reg, reg instruction without any
123 ; machine verifier errors.
124 ; CHECK-LABEL: logicalReg:
125 ; CHECK: orr w{{[0-9]+}}, w{{[0-9]+}}, w{{[0-9]+}}
128 br i1 undef, label %cond.end, label %cond.false
131 %cond = select i1 undef, i1 true, i1 false
135 %cond13 = phi i1 [ %cond, %cond.false ], [ true, %entry ]