1 ; RUN: llc < %s -march=xcore | FileCheck %s
3 @a = external dso_local constant [0 x i32], section ".cp.rodata"
4 @b = external dso_local global [0 x i32]
6 define i32 *@f1() nounwind {
9 ; CHECK: ldaw r11, cp[a+4]
11 %0 = getelementptr [0 x i32], [0 x i32]* @a, i32 0, i32 1
15 define i32 *@f2() nounwind {
18 ; CHECK: ldaw r0, dp[b+4]
19 %0 = getelementptr [0 x i32], [0 x i32]* @b, i32 0, i32 1
23 ; Don't fold negative offsets into cp / dp accesses to avoid a relocation
24 ; error if the address + addend is less than the start of the cp / dp.
26 define i32 *@f3() nounwind {
29 ; CHECK: ldaw r11, cp[a]
30 ; CHECK: sub r0, r11, 4
31 %0 = getelementptr [0 x i32], [0 x i32]* @a, i32 0, i32 -1
35 define i32 *@f4() nounwind {
38 ; CHECK: ldaw [[REG:r[0-9]+]], dp[b]
39 ; CHECK: sub r0, [[REG]], 4
40 %0 = getelementptr [0 x i32], [0 x i32]* @b, i32 0, i32 -1