xref: /aosp_15_r20/external/llvm/test/CodeGen/ARM/cse-ldrlit.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple=thumbv6m-apple-none-macho -relocation-model=pic -o -  %s | FileCheck %s --check-prefix=CHECK-THUMB-PIC
2*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple=arm-apple-none-macho -relocation-model=pic -o -  %s | FileCheck %s --check-prefix=CHECK-ARM-PIC
3*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple=thumbv6m-apple-none-macho -relocation-model=dynamic-no-pic -o -  %s | FileCheck %s --check-prefix=CHECK-DYNAMIC
4*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple=arm-apple-none-macho -relocation-model=dynamic-no-pic -o -  %s | FileCheck %s --check-prefix=CHECK-DYNAMIC
5*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple=thumbv6m-apple-none-macho -relocation-model=static -o -  %s | FileCheck %s --check-prefix=CHECK-STATIC
6*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple=arm-apple-none-macho -relocation-model=static -o -  %s | FileCheck %s --check-prefix=CHECK-STATIC
7*9880d681SAndroid Build Coastguard Worker@var = global [16 x i32] zeroinitializer
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Workerdeclare void @bar(i32*)
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Workerdefine void @foo() {
12*9880d681SAndroid Build Coastguard Worker  %flag = load i32, i32* getelementptr inbounds([16 x i32], [16 x i32]* @var, i32 0, i32 1)
13*9880d681SAndroid Build Coastguard Worker  %tst = icmp eq i32 %flag, 0
14*9880d681SAndroid Build Coastguard Worker  br i1 %tst, label %true, label %false
15*9880d681SAndroid Build Coastguard Workertrue:
16*9880d681SAndroid Build Coastguard Worker  tail call void @bar(i32* getelementptr inbounds([16 x i32], [16 x i32]* @var, i32 0, i32 4))
17*9880d681SAndroid Build Coastguard Worker  ret void
18*9880d681SAndroid Build Coastguard Workerfalse:
19*9880d681SAndroid Build Coastguard Worker  ret void
20*9880d681SAndroid Build Coastguard Worker}
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Worker; CHECK-THUMB-PIC-LABEL: foo:
23*9880d681SAndroid Build Coastguard Worker; CHECK-THUMB-PIC: ldr r0, LCPI0_0
24*9880d681SAndroid Build Coastguard Worker; CHECK-THUMB-PIC: LPC0_0:
25*9880d681SAndroid Build Coastguard Worker; CHECK-THUMB-PIC-NEXT: add r0, pc
26*9880d681SAndroid Build Coastguard Worker; CHECK-THUMB-PIC: ldr {{r[1-9][0-9]?}}, [r0, #4]
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Worker; CHECK-THUMB-PIC: LCPI0_0:
29*9880d681SAndroid Build Coastguard Worker; CHECK-THUMB-PIC-NEXT: .long _var-(LPC0_0+4)
30*9880d681SAndroid Build Coastguard Worker; CHECK-THUMB-PIC-NOT: LCPI0_1
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Worker
33*9880d681SAndroid Build Coastguard Worker; CHECK-ARM-PIC-LABEL: foo:
34*9880d681SAndroid Build Coastguard Worker; CHECK-ARM-PIC: ldr [[VAR_OFFSET:r[0-9]+]], LCPI0_0
35*9880d681SAndroid Build Coastguard Worker; CHECK-ARM-PIC: LPC0_0:
36*9880d681SAndroid Build Coastguard Worker; CHECK-ARM-PIC-NEXT: add r0, pc, [[VAR_OFFSET]]
37*9880d681SAndroid Build Coastguard Worker; CHECK-ARM-PIC: ldr {{r[0-9]+}}, [r0, #4]
38*9880d681SAndroid Build Coastguard Worker
39*9880d681SAndroid Build Coastguard Worker; CHECK-ARM-PIC: LCPI0_0:
40*9880d681SAndroid Build Coastguard Worker; CHECK-ARM-PIC-NEXT: .long _var-(LPC0_0+8)
41*9880d681SAndroid Build Coastguard Worker; CHECK-ARM-PIC-NOT: LCPI0_1
42*9880d681SAndroid Build Coastguard Worker
43*9880d681SAndroid Build Coastguard Worker
44*9880d681SAndroid Build Coastguard Worker; CHECK-DYNAMIC-LABEL: foo:
45*9880d681SAndroid Build Coastguard Worker; CHECK-DYNAMIC: ldr r0, LCPI0_0
46*9880d681SAndroid Build Coastguard Worker; CHECK-DYNAMIC: ldr {{r[1-9][0-9]?}}, [r0, #4]
47*9880d681SAndroid Build Coastguard Worker
48*9880d681SAndroid Build Coastguard Worker; CHECK-DYNAMIC: LCPI0_0:
49*9880d681SAndroid Build Coastguard Worker; CHECK-DYNAMIC-NEXT: .long _var
50*9880d681SAndroid Build Coastguard Worker; CHECK-DYNAMIC-NOT: LCPI0_1
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Worker
53*9880d681SAndroid Build Coastguard Worker; CHECK-STATIC-LABEL: foo:
54*9880d681SAndroid Build Coastguard Worker; CHECK-STATIC: ldr r0, LCPI0_0
55*9880d681SAndroid Build Coastguard Worker; CHECK-STATIC: ldr {{r[1-9][0-9]?}}, [r0, #4]
56*9880d681SAndroid Build Coastguard Worker
57*9880d681SAndroid Build Coastguard Worker; CHECK-STATIC: LCPI0_0:
58*9880d681SAndroid Build Coastguard Worker; CHECK-STATIC-NEXT: .long _var{{$}}
59*9880d681SAndroid Build Coastguard Worker; CHECK-STATIC-NOT: LCPI0_1
60*9880d681SAndroid Build Coastguard Worker
61*9880d681SAndroid Build Coastguard Worker
62