1 ; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=armv7-apple-darwin | FileCheck %s --check-prefix=ARM
2 ; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-darwin | FileCheck %s --check-prefix=THUMB
4 ; Very basic fast-isel functionality.
5 define i32 @add(i32 %a, i32 %b) nounwind {
7 %a.addr = alloca i32, align 4
8 %b.addr = alloca i32, align 4
9 store i32 %a, i32* %a.addr
10 store i32 %b, i32* %b.addr
11 %tmp = load i32* %a.addr
12 %tmp1 = load i32* %b.addr
13 %add = add nsw i32 %tmp, %tmp1
17 ; Check truncate to bool
18 define void @test1(i32 %tmp) nounwind {
20 %tobool = trunc i32 %tmp to i1
21 br i1 %tobool, label %if.then, label %if.end
23 if.then: ; preds = %entry
24 call void @test1(i32 0)
27 if.end: ; preds = %if.then, %entry
35 ; Check some simple operations with immediates
36 define void @test2(i32 %tmp, i32* %ptr) nounwind {
41 %a = add i32 %tmp, 4096
42 store i32 %a, i32* %ptr
45 ; THUMB: add.w {{.*}} #4096
46 ; ARM: add {{.*}} #4096
49 %b = add i32 %tmp, 4095
50 store i32 %b, i32* %ptr
52 ; THUMB: addw {{.*}} #4095
53 ; ARM: movw {{.*}} #4095
58 store i32 %c, i32* %ptr
61 ; THUMB: orr {{.*}} #4
65 define void @test3(i32 %tmp, i32* %ptr1, i16* %ptr2, i8* %ptr3) nounwind {
70 %a1 = trunc i32 %tmp to i16
71 %a2 = trunc i16 %a1 to i8
72 %a3 = trunc i8 %a2 to i1
73 %a4 = zext i1 %a3 to i8
74 store i8 %a4, i8* %ptr3
75 %a5 = zext i8 %a4 to i16
76 store i16 %a5, i16* %ptr2
77 %a6 = zext i16 %a5 to i32
78 store i32 %a6, i32* %ptr1
93 %b1 = trunc i32 %tmp to i16
94 %b2 = trunc i16 %b1 to i8
95 store i8 %b2, i8* %ptr3
96 %b3 = sext i8 %b2 to i16
97 store i16 %b3, i16* %ptr2
98 %b4 = sext i16 %b3 to i32
99 store i32 %b4, i32* %ptr1
113 %c2 = load i16* %ptr2
114 %c3 = load i32* %ptr1
115 %c4 = zext i8 %c1 to i32
116 %c5 = sext i16 %c2 to i32
117 %c6 = add i32 %c4, %c5
118 %c7 = sub i32 %c3, %c6
119 store i32 %c7, i32* %ptr1
136 ; Check loads/stores with globals
137 @test4g = external global i32
139 define void @test4() {
140 %a = load i32* @test4g
142 store i32 %b, i32* @test4g
145 ; THUMB: ldr.n r0, LCPI4_1
146 ; THUMB: ldr r0, [r0]
147 ; THUMB: ldr r0, [r0]
149 ; THUMB: ldr.n r1, LCPI4_0
150 ; THUMB: ldr r1, [r1]
151 ; THUMB: str r0, [r1]
153 ; ARM: ldr r0, LCPI4_1
156 ; ARM: add r0, r0, #1
157 ; ARM: ldr r1, LCPI4_0