1 ; RUN: llc -mtriple=thumb-eabi -mcpu=arm1156t2-s -mattr=+thumb2 %s -o - | FileCheck %s 2 3 define i32 @f1(i32* %v) { 4 entry: 5 ; CHECK-LABEL: f1: 6 ; CHECK: ldr r0, [r0] 7 %tmp = load i32, i32* %v 8 ret i32 %tmp 9 } 10 11 define i32 @f2(i32* %v) { 12 entry: 13 ; CHECK-LABEL: f2: 14 ; CHECK: ldr.w r0, [r0, #4092] 15 %tmp2 = getelementptr i32, i32* %v, i32 1023 16 %tmp = load i32, i32* %tmp2 17 ret i32 %tmp 18 } 19 20 define i32 @f3(i32* %v) { 21 entry: 22 ; CHECK-LABEL: f3: 23 ; CHECK: mov.w r1, #4096 24 ; CHECK: ldr r0, [r0, r1] 25 %tmp2 = getelementptr i32, i32* %v, i32 1024 26 %tmp = load i32, i32* %tmp2 27 ret i32 %tmp 28 } 29 30 define i32 @f4(i32 %base) { 31 entry: 32 ; CHECK-LABEL: f4: 33 ; CHECK: ldr r0, [r0, #-128] 34 %tmp1 = sub i32 %base, 128 35 %tmp2 = inttoptr i32 %tmp1 to i32* 36 %tmp3 = load i32, i32* %tmp2 37 ret i32 %tmp3 38 } 39 40 define i32 @f5(i32 %base, i32 %offset) { 41 entry: 42 ; CHECK-LABEL: f5: 43 ; CHECK: ldr r0, [r0, r1] 44 %tmp1 = add i32 %base, %offset 45 %tmp2 = inttoptr i32 %tmp1 to i32* 46 %tmp3 = load i32, i32* %tmp2 47 ret i32 %tmp3 48 } 49 50 define i32 @f6(i32 %base, i32 %offset) { 51 entry: 52 ; CHECK-LABEL: f6: 53 ; CHECK: ldr.w r0, [r0, r1, lsl #2] 54 %tmp1 = shl i32 %offset, 2 55 %tmp2 = add i32 %base, %tmp1 56 %tmp3 = inttoptr i32 %tmp2 to i32* 57 %tmp4 = load i32, i32* %tmp3 58 ret i32 %tmp4 59 } 60 61 define i32 @f7(i32 %base, i32 %offset) { 62 entry: 63 ; CHECK-LABEL: f7: 64 ; CHECK: lsrs r1, r1, #2 65 ; CHECK: ldr r0, [r0, r1] 66 67 %tmp1 = lshr i32 %offset, 2 68 %tmp2 = add i32 %base, %tmp1 69 %tmp3 = inttoptr i32 %tmp2 to i32* 70 %tmp4 = load i32, i32* %tmp3 71 ret i32 %tmp4 72 } 73