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