ARM: recommit r237590: allow jump tables to be placed as constant islands.
[oota-llvm.git] / test / CodeGen / ARM / jump-table-islands-split.ll
1 ; RUN: llc -mtriple=thumbv7s-apple-ios8.0 -o - %s | FileCheck %s
2
3 declare void @foo(double)
4 declare i32 @llvm.arm.space(i32, i32)
5
6 ; The constpool entry used to call @foo should be directly between where we want
7 ; the tbb and its table. Fortunately, the flow is simple enough that we can
8 ; eliminate the entry calculation (ADD) and use the ADR as the base.
9 ;
10 ; I'm hoping this won't be fragile, but if it does break the most likely fix is
11 ; adjusting the @llvm.arm.space call slightly. If this happens too many times
12 ; the test should probably be removed.
13 define i32 @test_jumptable_not_adjacent(i1 %tst, i32 %sw, i32 %l) {
14 ; CHECK-LABEL: test_jumptable_not_adjacent:
15 ; CHECK:     vldr {{d[0-9]+}}, [[DBL_CONST:LCPI[0-9]+_[0-9]+]]
16 ; [...]
17 ; CHECK:     adr.w r[[BASE:[0-9]+]], [[JUMP_TABLE:LJTI[0-9]+_[0-9]+]]
18 ; CHECK-NOT: r[[BASE]]
19
20 ; CHECK: [[TBB_KEY:LCPI[0-9]+_[0-9]+]]:
21 ; CHECK-NEXT:     tbb [r[[BASE]], {{r[0-9]+}}]
22
23 ; CHECK: [[DBL_CONST]]:
24 ; CHECK:     .long
25 ; CHECK:     .long
26 ; CHECK: [[JUMP_TABLE]]:
27 ; CHECK:     .byte (LBB{{[0-9]+}}_{{[0-9]+}}-([[TBB_KEY]]+4)
28
29   br label %complex
30
31 complex:
32   call void @foo(double 12345.0)
33   call i32 @llvm.arm.space(i32 970, i32 undef)
34   switch i32 %sw, label %second [ i32 0, label %other
35                                   i32 1, label %third
36                                   i32 2, label %end
37                                   i32 3, label %other ]
38
39 second:
40   ret i32 43
41 third:
42   ret i32 0
43
44 other:
45   call void @bar()
46   unreachable
47
48 end:
49   ret i32 42
50 }
51
52 declare void @bar()