1 ; RUN: llc < %s -code-model=small | FileCheck -check-prefix CHECK-SMALL %s 2 ; RUN: llc < %s -code-model=kernel | FileCheck -check-prefix CHECK-KERNEL %s 3 4 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" 5 target triple = "x86_64-unknown-linux-gnu" 6 @data = external global [0 x i32] ; <[0 x i32]*> [#uses=5] 7 8 define i32 @foo() nounwind readonly { 9 entry: 10 ; CHECK-SMALL-LABEL: foo: 11 ; CHECK-SMALL: movl data(%rip), %eax 12 ; CHECK-KERNEL-LABEL: foo: 13 ; CHECK-KERNEL: movl data, %eax 14 %0 = load i32* getelementptr ([0 x i32]* @data, i64 0, i64 0), align 4 ; <i32> [#uses=1] 15 ret i32 %0 16 } 17 18 define i32 @foo2() nounwind readonly { 19 entry: 20 ; CHECK-SMALL-LABEL: foo2: 21 ; CHECK-SMALL: movl data+40(%rip), %eax 22 ; CHECK-KERNEL-LABEL: foo2: 23 ; CHECK-KERNEL: movl data+40, %eax 24 %0 = load i32* getelementptr ([0 x i32]* @data, i32 0, i64 10), align 4 ; <i32> [#uses=1] 25 ret i32 %0 26 } 27 28 define i32 @foo3() nounwind readonly { 29 entry: 30 ; CHECK-SMALL-LABEL: foo3: 31 ; CHECK-SMALL: movl data-40(%rip), %eax 32 ; CHECK-KERNEL-LABEL: foo3: 33 ; CHECK-KERNEL: movq $-40, %rax 34 %0 = load i32* getelementptr ([0 x i32]* @data, i32 0, i64 -10), align 4 ; <i32> [#uses=1] 35 ret i32 %0 36 } 37 38 define i32 @foo4() nounwind readonly { 39 entry: 40 ; FIXME: We really can use movabsl here! 41 ; CHECK-SMALL-LABEL: foo4: 42 ; CHECK-SMALL: movl $16777216, %eax 43 ; CHECK-SMALL: movl data(%rax), %eax 44 ; CHECK-KERNEL-LABEL: foo4: 45 ; CHECK-KERNEL: movl data+16777216, %eax 46 %0 = load i32* getelementptr ([0 x i32]* @data, i32 0, i64 4194304), align 4 ; <i32> [#uses=1] 47 ret i32 %0 48 } 49 50 define i32 @foo1() nounwind readonly { 51 entry: 52 ; CHECK-SMALL-LABEL: foo1: 53 ; CHECK-SMALL: movl data+16777212(%rip), %eax 54 ; CHECK-KERNEL-LABEL: foo1: 55 ; CHECK-KERNEL: movl data+16777212, %eax 56 %0 = load i32* getelementptr ([0 x i32]* @data, i32 0, i64 4194303), align 4 ; <i32> [#uses=1] 57 ret i32 %0 58 } 59 define i32 @foo5() nounwind readonly { 60 entry: 61 ; CHECK-SMALL-LABEL: foo5: 62 ; CHECK-SMALL: movl data-16777216(%rip), %eax 63 ; CHECK-KERNEL-LABEL: foo5: 64 ; CHECK-KERNEL: movq $-16777216, %rax 65 %0 = load i32* getelementptr ([0 x i32]* @data, i32 0, i64 -4194304), align 4 ; <i32> [#uses=1] 66 ret i32 %0 67 } 68