blob: 3f8fd75f49f943b1c7bb5157e6f57164eb113dfe [file] [log] [blame]
Evan Cheng3568a102011-11-08 21:21:09 +00001; RUN: llc < %s -mtriple=thumbv7-apple-ios -mcpu=cortex-a8 -regalloc=fast | FileCheck %s -check-prefix=A8
2; RUN: llc < %s -mtriple=thumbv7-apple-ios -mcpu=cortex-m3 -regalloc=fast | FileCheck %s -check-prefix=M3
3; rdar://6949835
Andrew Trick08c66642012-01-11 03:56:08 +00004; RUN: llc < %s -mtriple=thumbv7-apple-ios -mcpu=cortex-a8 -regalloc=basic | FileCheck %s -check-prefix=BASIC
5; RUN: llc < %s -mtriple=thumbv7-apple-ios -mcpu=cortex-a8 -regalloc=greedy | FileCheck %s -check-prefix=GREEDY
Evan Cheng358dec52009-06-15 08:28:29 +00006
Evan Cheng3568a102011-11-08 21:21:09 +00007; Magic ARM pair hints works best with linearscan / fast.
8
9; Cortex-M3 errata 602117: LDRD with base in list may result in incorrect base
10; register when interrupted or faulted.
Jakob Stoklund Olesenca6fd002011-03-31 22:14:03 +000011
Evan Cheng358dec52009-06-15 08:28:29 +000012@b = external global i64*
13
14define i64 @t(i64 %a) nounwind readonly {
15entry:
Evan Cheng3568a102011-11-08 21:21:09 +000016; A8: t:
17; A8: ldrd r2, r3, [r2]
Evan Cheng9fde6ca2009-09-26 02:41:17 +000018
Evan Cheng3568a102011-11-08 21:21:09 +000019; M3: t:
20; M3-NOT: ldrd
21; M3: ldm.w r2, {r2, r3}
Evan Cheng9fde6ca2009-09-26 02:41:17 +000022
Evan Cheng358dec52009-06-15 08:28:29 +000023 %0 = load i64** @b, align 4
24 %1 = load i64* %0, align 4
25 %2 = mul i64 %1, %a
26 ret i64 %2
27}
Andrew Trick08c66642012-01-11 03:56:08 +000028
29; rdar://10435045 mixed LDRi8/LDRi12
30;
31; In this case, LSR generate a sequence of LDRi8/LDRi12. We should be
32; able to generate an LDRD pair here, but this is highly sensitive to
33; regalloc hinting. So, this doubles as a register allocation
34; test. RABasic currently does a better job within the inner loop
35; because of its *lack* of hinting ability. Whereas RAGreedy keeps
36; R0/R1/R2 live as the three arguments, forcing the LDRD's odd
37; destination into R3. We then sensibly split LDRD again rather then
38; evict another live range or use callee saved regs. Sorry if the test
39; is sensitive to Regalloc changes, but it is an interesting case.
40;
41; BASIC: @f
42; BASIC: %bb
43; BASIC: ldrd
44; BASIC: str
45; GREEDY: @f
46; GREEDY: %bb
Jakob Stoklund Olesene3b23cd2012-04-02 22:30:39 +000047; GREEDY: ldrd
Andrew Trick08c66642012-01-11 03:56:08 +000048; GREEDY: str
49define void @f(i32* nocapture %a, i32* nocapture %b, i32 %n) nounwind {
50entry:
51 %0 = add nsw i32 %n, -1 ; <i32> [#uses=2]
52 %1 = icmp sgt i32 %0, 0 ; <i1> [#uses=1]
53 br i1 %1, label %bb, label %return
54
55bb: ; preds = %bb, %entry
56 %i.03 = phi i32 [ %tmp, %bb ], [ 0, %entry ] ; <i32> [#uses=3]
57 %scevgep = getelementptr i32* %a, i32 %i.03 ; <i32*> [#uses=1]
58 %scevgep4 = getelementptr i32* %b, i32 %i.03 ; <i32*> [#uses=1]
59 %tmp = add i32 %i.03, 1 ; <i32> [#uses=3]
60 %scevgep5 = getelementptr i32* %a, i32 %tmp ; <i32*> [#uses=1]
61 %2 = load i32* %scevgep, align 4 ; <i32> [#uses=1]
62 %3 = load i32* %scevgep5, align 4 ; <i32> [#uses=1]
63 %4 = add nsw i32 %3, %2 ; <i32> [#uses=1]
64 store i32 %4, i32* %scevgep4, align 4
65 %exitcond = icmp eq i32 %tmp, %0 ; <i1> [#uses=1]
66 br i1 %exitcond, label %return, label %bb
67
68return: ; preds = %bb, %entry
69 ret void
70}