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