Home | History | Annotate | Download | only in SystemZ
      1 ; Test moves of integers to 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(i8 *%ptr) {
      7 ; CHECK-LABEL: f1:
      8 ; CHECK: mvi 0(%r2), 0
      9 ; CHECK: br %r14
     10   store i8 0, i8 *%ptr
     11   ret void
     12 }
     13 
     14 ; Check the high end of the signed range.
     15 define void @f2(i8 *%ptr) {
     16 ; CHECK-LABEL: f2:
     17 ; CHECK: mvi 0(%r2), 127
     18 ; CHECK: br %r14
     19   store i8 127, i8 *%ptr
     20   ret void
     21 }
     22 
     23 ; Check the next value up.
     24 define void @f3(i8 *%ptr) {
     25 ; CHECK-LABEL: f3:
     26 ; CHECK: mvi 0(%r2), 128
     27 ; CHECK: br %r14
     28   store i8 -128, i8 *%ptr
     29   ret void
     30 }
     31 
     32 ; Check the high end of the unsigned range.
     33 define void @f4(i8 *%ptr) {
     34 ; CHECK-LABEL: f4:
     35 ; CHECK: mvi 0(%r2), 255
     36 ; CHECK: br %r14
     37   store i8 255, i8 *%ptr
     38   ret void
     39 }
     40 
     41 ; Check -1.
     42 define void @f5(i8 *%ptr) {
     43 ; CHECK-LABEL: f5:
     44 ; CHECK: mvi 0(%r2), 255
     45 ; CHECK: br %r14
     46   store i8 -1, i8 *%ptr
     47   ret void
     48 }
     49 
     50 ; Check the low end of the signed range.
     51 define void @f6(i8 *%ptr) {
     52 ; CHECK-LABEL: f6:
     53 ; CHECK: mvi 0(%r2), 128
     54 ; CHECK: br %r14
     55   store i8 -128, i8 *%ptr
     56   ret void
     57 }
     58 
     59 ; Check the next value down.
     60 define void @f7(i8 *%ptr) {
     61 ; CHECK-LABEL: f7:
     62 ; CHECK: mvi 0(%r2), 127
     63 ; CHECK: br %r14
     64   store i8 -129, i8 *%ptr
     65   ret void
     66 }
     67 
     68 ; Check the high end of the MVI range.
     69 define void @f8(i8 *%src) {
     70 ; CHECK-LABEL: f8:
     71 ; CHECK: mvi 4095(%r2), 42
     72 ; CHECK: br %r14
     73   %ptr = getelementptr i8, i8 *%src, i64 4095
     74   store i8 42, i8 *%ptr
     75   ret void
     76 }
     77 
     78 ; Check the next byte up, which should use MVIY instead of MVI.
     79 define void @f9(i8 *%src) {
     80 ; CHECK-LABEL: f9:
     81 ; CHECK: mviy 4096(%r2), 42
     82 ; CHECK: br %r14
     83   %ptr = getelementptr i8, i8 *%src, i64 4096
     84   store i8 42, i8 *%ptr
     85   ret void
     86 }
     87 
     88 ; Check the high end of the MVIY range.
     89 define void @f10(i8 *%src) {
     90 ; CHECK-LABEL: f10:
     91 ; CHECK: mviy 524287(%r2), 42
     92 ; CHECK: br %r14
     93   %ptr = getelementptr i8, i8 *%src, i64 524287
     94   store i8 42, i8 *%ptr
     95   ret void
     96 }
     97 
     98 ; Check the next byte up, which needs separate address logic.
     99 ; Other sequences besides this one would be OK.
    100 define void @f11(i8 *%src) {
    101 ; CHECK-LABEL: f11:
    102 ; CHECK: agfi %r2, 524288
    103 ; CHECK: mvi 0(%r2), 42
    104 ; CHECK: br %r14
    105   %ptr = getelementptr i8, i8 *%src, i64 524288
    106   store i8 42, i8 *%ptr
    107   ret void
    108 }
    109 
    110 ; Check the high end of the negative MVIY range.
    111 define void @f12(i8 *%src) {
    112 ; CHECK-LABEL: f12:
    113 ; CHECK: mviy -1(%r2), 42
    114 ; CHECK: br %r14
    115   %ptr = getelementptr i8, i8 *%src, i64 -1
    116   store i8 42, i8 *%ptr
    117   ret void
    118 }
    119 
    120 ; Check the low end of the MVIY range.
    121 define void @f13(i8 *%src) {
    122 ; CHECK-LABEL: f13:
    123 ; CHECK: mviy -524288(%r2), 42
    124 ; CHECK: br %r14
    125   %ptr = getelementptr i8, i8 *%src, i64 -524288
    126   store i8 42, i8 *%ptr
    127   ret void
    128 }
    129 
    130 ; Check the next byte down, which needs separate address logic.
    131 ; Other sequences besides this one would be OK.
    132 define void @f14(i8 *%src) {
    133 ; CHECK-LABEL: f14:
    134 ; CHECK: agfi %r2, -524289
    135 ; CHECK: mvi 0(%r2), 42
    136 ; CHECK: br %r14
    137   %ptr = getelementptr i8, i8 *%src, i64 -524289
    138   store i8 42, i8 *%ptr
    139   ret void
    140 }
    141 
    142 ; Check that MVI does not allow an index.  We prefer STC in that case.
    143 define void @f15(i64 %src, i64 %index) {
    144 ; CHECK-LABEL: f15:
    145 ; CHECK: lhi [[TMP:%r[0-5]]], 42
    146 ; CHECK: stc [[TMP]], 4095({{%r2,%r3|%r3,%r2}}
    147 ; CHECK: br %r14
    148   %add1 = add i64 %src, %index
    149   %add2 = add i64 %add1, 4095
    150   %ptr = inttoptr i64 %add2 to i8 *
    151   store i8 42, i8 *%ptr
    152   ret void
    153 }
    154 
    155 ; Check that MVIY does not allow an index.  We prefer STCY in that case.
    156 define void @f16(i64 %src, i64 %index) {
    157 ; CHECK-LABEL: f16:
    158 ; CHECK: lhi [[TMP:%r[0-5]]], 42
    159 ; CHECK: stcy [[TMP]], 4096({{%r2,%r3|%r3,%r2}}
    160 ; CHECK: br %r14
    161   %add1 = add i64 %src, %index
    162   %add2 = add i64 %add1, 4096
    163   %ptr = inttoptr i64 %add2 to i8 *
    164   store i8 42, i8 *%ptr
    165   ret void
    166 }
    167