1 ; RUN: llc -mtriple=thumb-eabi %s -verify-machineinstrs -o - | \
2 ; RUN: FileCheck %s -check-prefix CHECK --check-prefix CHECK-EABI
3 ; RUN: llc -mtriple=thumb-apple-darwin %s -verify-machineinstrs -o - | \
4 ; RUN: FileCheck %s -check-prefix CHECK -check-prefix CHECK-DARWIN
35 ; CHECK: lsls r0, r0, #31
41 ret i64 9223372036854775807
48 define i64 @f6(i64 %x, i64 %y) {
50 %tmp1 = add i64 %y, 1 ; <i64> [#uses=1]
54 ; CHECK: adds r0, r2, #1
58 define i64 @f6a(i64 %x, i64 %y) {
60 %tmp1 = add i64 %y, 10
69 define i64 @f6b(i64 %x, i64 %y) {
71 %tmp1 = add i64 %y, 1000
74 ; CHECK: movs r0, #125
75 ; CHECK: lsls r0, r0, #3
77 ; CHECK: adds r0, r2, r0
83 %tmp = call i64 @f8( ) ; <i64> [#uses=0]
91 define i64 @f9(i64 %a, i64 %b) {
93 %tmp = sub i64 %a, %b ; <i64> [#uses=1]
96 ; CHECK: subs r0, r0, r2
100 define i64 @f9a(i64 %x, i64 %y) { ; ADDC with small negative imm => SUBS imm
102 %tmp1 = sub i64 %y, 10
108 ; CHECK: subs r0, #10
112 define i64 @f9b(i64 %x, i64 %y) { ; ADDC with big negative imm => SUBS reg
114 %tmp1 = sub i64 1000, %y
117 ; CHECK: movs r0, #125
118 ; CHECK: lsls r0, r0, #3
120 ; CHECK: subs r0, r0, r2
124 define i64 @f9c(i64 %x, i32 %y) { ; SUBS with small positive imm => SUBS imm
126 %conv = sext i32 %y to i64
127 %shl = shl i64 %conv, 32
129 %sub = sub nsw i64 %x, %or
132 ; CHECK: subs r0, r0, #1
136 define i64 @f9d(i64 %x, i32 %y) { ; SUBS with small negative imm => ADDS imm
138 %conv = sext i32 %y to i64
139 %shl = shl i64 %conv, 32
140 %or = or i64 %shl, 4294967295
141 %sub = sub nsw i64 %x, %or
144 ; CHECK: adds r0, r0, #1
148 define i64 @f(i32 %a, i32 %b) {
150 %tmp = sext i32 %a to i64 ; <i64> [#uses=1]
151 %tmp1 = sext i32 %b to i64 ; <i64> [#uses=1]
152 %tmp2 = mul i64 %tmp1, %tmp ; <i64> [#uses=1]
155 ; CHECK-V6: bl __aeabi_lmul
156 ; CHECK-DARWIN: __muldi3
159 define i64 @g(i32 %a, i32 %b) {
161 %tmp = zext i32 %a to i64 ; <i64> [#uses=1]
162 %tmp1 = zext i32 %b to i64 ; <i64> [#uses=1]
163 %tmp2 = mul i64 %tmp1, %tmp ; <i64> [#uses=1]
166 ; CHECK-V6: bl __aeabi_lmul
167 ; CHECK-DARWIN: __muldi3
172 %a = alloca i64, align 8 ; <i64*> [#uses=1]
173 %retval = load i64, i64* %a ; <i64> [#uses=1]
176 ; CHECK-EABI: sub sp, #8
177 ; CHECK-DARWIN: add r7, sp, #4
178 ; CHECK: ldr r0, [sp]
179 ; CHECK: ldr r1, [sp, #4]
180 ; CHECK-EABI: add sp, #8
181 ; CHECK-DARWIN: mov sp, r4
184 define i64 @f11(i64 %x, i64 %y) {
186 %tmp1 = add i64 -1000, %y
187 %tmp2 = add i64 %tmp1, -1000
191 ; CHECK: movs r0, #125
192 ; CHECK: lsls r0, r0, #3
194 ; CHECK: subs r2, r2, r0
196 ; CHECK: subs r0, r2, r0
200 ; "sub 2147483648" has to be lowered into "add -2147483648"
201 define i64 @f12(i64 %x, i64 %y) {
203 %tmp1 = sub i64 %x, 2147483648
207 ; CHECK: lsls r2, r2, #31
209 ; CHECK: adds r0, r0, r2
213 declare void @f13(i64 %x)
215 define void @f14(i1 %x, i64 %y) #0 {
219 call void @f13(i64 %a)
221 br i1 %x, label %if.end, label %if.then
224 call void @f13(i64 %y)
230 call void @f13(i64 %b)
235 call void @f13(i64 %c)
242 attributes #0 = { optsize }