1 ; RUN: llc < %s -march=xcore | FileCheck %s 2 3 @a = external constant [0 x i32], section ".cp.rodata" 4 @b = external global [0 x i32] 5 6 define i32 *@f1() nounwind { 7 entry: 8 ; CHECK-LABEL: f1: 9 ; CHECK: ldaw r11, cp[a+4] 10 ; CHECK: mov r0, r11 11 %0 = getelementptr [0 x i32]* @a, i32 0, i32 1 12 ret i32* %0 13 } 14 15 define i32 *@f2() nounwind { 16 entry: 17 ; CHECK-LABEL: f2: 18 ; CHECK: ldaw r0, dp[b+4] 19 %0 = getelementptr [0 x i32]* @b, i32 0, i32 1 20 ret i32* %0 21 } 22 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. 25 26 define i32 *@f3() nounwind { 27 entry: 28 ; CHECK-LABEL: f3: 29 ; CHECK: ldaw r11, cp[a] 30 ; CHECK: sub r0, r11, 4 31 %0 = getelementptr [0 x i32]* @a, i32 0, i32 -1 32 ret i32* %0 33 } 34 35 define i32 *@f4() nounwind { 36 entry: 37 ; CHECK-LABEL: f4: 38 ; CHECK: ldaw [[REG:r[0-9]+]], dp[b] 39 ; CHECK: sub r0, [[REG]], 4 40 %0 = getelementptr [0 x i32]* @b, i32 0, i32 -1 41 ret i32* %0 42 } 43