Home | History | Annotate | Download | only in SystemZ
      1 ; Test moves of integers to 2-byte memory locations.
      2 ;
      3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
      4 
      5 ; Check the low end of the unsigned range.
      6 define void @f1(i16 *%ptr) {
      7 ; CHECK-LABEL: f1:
      8 ; CHECK: mvhhi 0(%r2), 0
      9 ; CHECK: br %r14
     10   store i16 0, i16 *%ptr
     11   ret void
     12 }
     13 
     14 ; Check the high end of the signed range.
     15 define void @f2(i16 *%ptr) {
     16 ; CHECK-LABEL: f2:
     17 ; CHECK: mvhhi 0(%r2), 32767
     18 ; CHECK: br %r14
     19   store i16 32767, i16 *%ptr
     20   ret void
     21 }
     22 
     23 ; Check the next value up.
     24 define void @f3(i16 *%ptr) {
     25 ; CHECK-LABEL: f3:
     26 ; CHECK: mvhhi 0(%r2), -32768
     27 ; CHECK: br %r14
     28   store i16 -32768, i16 *%ptr
     29   ret void
     30 }
     31 
     32 ; Check the high end of the unsigned range.
     33 define void @f4(i16 *%ptr) {
     34 ; CHECK-LABEL: f4:
     35 ; CHECK: mvhhi 0(%r2), -1
     36 ; CHECK: br %r14
     37   store i16 65535, i16 *%ptr
     38   ret void
     39 }
     40 
     41 ; Check -1.
     42 define void @f5(i16 *%ptr) {
     43 ; CHECK-LABEL: f5:
     44 ; CHECK: mvhhi 0(%r2), -1
     45 ; CHECK: br %r14
     46   store i16 -1, i16 *%ptr
     47   ret void
     48 }
     49 
     50 ; Check the low end of the signed range.
     51 define void @f6(i16 *%ptr) {
     52 ; CHECK-LABEL: f6:
     53 ; CHECK: mvhhi 0(%r2), -32768
     54 ; CHECK: br %r14
     55   store i16 -32768, i16 *%ptr
     56   ret void
     57 }
     58 
     59 ; Check the next value down.
     60 define void @f7(i16 *%ptr) {
     61 ; CHECK-LABEL: f7:
     62 ; CHECK: mvhhi 0(%r2), 32767
     63 ; CHECK: br %r14
     64   store i16 -32769, i16 *%ptr
     65   ret void
     66 }
     67 
     68 ; Check the high end of the MVHHI range.
     69 define void @f8(i16 *%a) {
     70 ; CHECK-LABEL: f8:
     71 ; CHECK: mvhhi 4094(%r2), 42
     72 ; CHECK: br %r14
     73   %ptr = getelementptr i16, i16 *%a, i64 2047
     74   store i16 42, i16 *%ptr
     75   ret void
     76 }
     77 
     78 ; Check the next halfword up, which is out of range.  We prefer STHY
     79 ; in that case.
     80 define void @f9(i16 *%a) {
     81 ; CHECK-LABEL: f9:
     82 ; CHECK: lhi [[TMP:%r[0-5]]], 42
     83 ; CHECK: sthy [[TMP]], 4096(%r2)
     84 ; CHECK: br %r14
     85   %ptr = getelementptr i16, i16 *%a, i64 2048
     86   store i16 42, i16 *%ptr
     87   ret void
     88 }
     89 
     90 ; Check negative displacements, for which we again prefer STHY.
     91 define void @f10(i16 *%a) {
     92 ; CHECK-LABEL: f10:
     93 ; CHECK: lhi [[TMP:%r[0-5]]], 42
     94 ; CHECK: sthy [[TMP]], -2(%r2)
     95 ; CHECK: br %r14
     96   %ptr = getelementptr i16, i16 *%a, i64 -1
     97   store i16 42, i16 *%ptr
     98   ret void
     99 }
    100 
    101 ; Check that MVHHI does not allow an index.
    102 define void @f11(i64 %src, i64 %index) {
    103 ; CHECK-LABEL: f11:
    104 ; CHECK: lhi [[TMP:%r[0-5]]], 42
    105 ; CHECK: sth [[TMP]], 0({{%r2,%r3|%r3,%r2}})
    106 ; CHECK: br %r14
    107   %add = add i64 %src, %index
    108   %ptr = inttoptr i64 %add to i16 *
    109   store i16 42, i16 *%ptr
    110   ret void
    111 }
    112