Home | History | Annotate | Download | only in SystemZ
      1 ; Test vector extraction.
      2 ;
      3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
      4 
      5 ; Test v16i8 extraction of the first element.
      6 define i8 @f1(<16 x i8> %val) {
      7 ; CHECK-LABEL: f1:
      8 ; CHECK: vlgvb %r2, %v24, 0
      9 ; CHECK: br %r14
     10   %ret = extractelement <16 x i8> %val, i32 0
     11   ret i8 %ret
     12 }
     13 
     14 ; Test v16i8 extraction of the last element.
     15 define i8 @f2(<16 x i8> %val) {
     16 ; CHECK-LABEL: f2:
     17 ; CHECK: vlgvb %r2, %v24, 15
     18 ; CHECK: br %r14
     19   %ret = extractelement <16 x i8> %val, i32 15
     20   ret i8 %ret
     21 }
     22 
     23 ; Test v16i8 extractions of an absurd element number.  This must compile
     24 ; but we don't care what it does.
     25 define i8 @f3(<16 x i8> %val) {
     26 ; CHECK-LABEL: f3:
     27 ; CHECK-NOT: vlgvb %r2, %v24, 100000
     28 ; CHECK: br %r14
     29   %ret = extractelement <16 x i8> %val, i32 100000
     30   ret i8 %ret
     31 }
     32 
     33 ; Test v16i8 extraction of a variable element.
     34 define i8 @f4(<16 x i8> %val, i32 %index) {
     35 ; CHECK-LABEL: f4:
     36 ; CHECK: vlgvb %r2, %v24, 0(%r2)
     37 ; CHECK: br %r14
     38   %ret = extractelement <16 x i8> %val, i32 %index
     39   ret i8 %ret
     40 }
     41 
     42 ; Test v8i16 extraction of the first element.
     43 define i16 @f5(<8 x i16> %val) {
     44 ; CHECK-LABEL: f5:
     45 ; CHECK: vlgvh %r2, %v24, 0
     46 ; CHECK: br %r14
     47   %ret = extractelement <8 x i16> %val, i32 0
     48   ret i16 %ret
     49 }
     50 
     51 ; Test v8i16 extraction of the last element.
     52 define i16 @f6(<8 x i16> %val) {
     53 ; CHECK-LABEL: f6:
     54 ; CHECK: vlgvh %r2, %v24, 7
     55 ; CHECK: br %r14
     56   %ret = extractelement <8 x i16> %val, i32 7
     57   ret i16 %ret
     58 }
     59 
     60 ; Test v8i16 extractions of an absurd element number.  This must compile
     61 ; but we don't care what it does.
     62 define i16 @f7(<8 x i16> %val) {
     63 ; CHECK-LABEL: f7:
     64 ; CHECK-NOT: vlgvh %r2, %v24, 100000
     65 ; CHECK: br %r14
     66   %ret = extractelement <8 x i16> %val, i32 100000
     67   ret i16 %ret
     68 }
     69 
     70 ; Test v8i16 extraction of a variable element.
     71 define i16 @f8(<8 x i16> %val, i32 %index) {
     72 ; CHECK-LABEL: f8:
     73 ; CHECK: vlgvh %r2, %v24, 0(%r2)
     74 ; CHECK: br %r14
     75   %ret = extractelement <8 x i16> %val, i32 %index
     76   ret i16 %ret
     77 }
     78 
     79 ; Test v4i32 extraction of the first element.
     80 define i32 @f9(<4 x i32> %val) {
     81 ; CHECK-LABEL: f9:
     82 ; CHECK: vlgvf %r2, %v24, 0
     83 ; CHECK: br %r14
     84   %ret = extractelement <4 x i32> %val, i32 0
     85   ret i32 %ret
     86 }
     87 
     88 ; Test v4i32 extraction of the last element.
     89 define i32 @f10(<4 x i32> %val) {
     90 ; CHECK-LABEL: f10:
     91 ; CHECK: vlgvf %r2, %v24, 3
     92 ; CHECK: br %r14
     93   %ret = extractelement <4 x i32> %val, i32 3
     94   ret i32 %ret
     95 }
     96 
     97 ; Test v4i32 extractions of an absurd element number.  This must compile
     98 ; but we don't care what it does.
     99 define i32 @f11(<4 x i32> %val) {
    100 ; CHECK-LABEL: f11:
    101 ; CHECK-NOT: vlgvf %r2, %v24, 100000
    102 ; CHECK: br %r14
    103   %ret = extractelement <4 x i32> %val, i32 100000
    104   ret i32 %ret
    105 }
    106 
    107 ; Test v4i32 extraction of a variable element.
    108 define i32 @f12(<4 x i32> %val, i32 %index) {
    109 ; CHECK-LABEL: f12:
    110 ; CHECK: vlgvf %r2, %v24, 0(%r2)
    111 ; CHECK: br %r14
    112   %ret = extractelement <4 x i32> %val, i32 %index
    113   ret i32 %ret
    114 }
    115 
    116 ; Test v2i64 extraction of the first element.
    117 define i64 @f13(<2 x i64> %val) {
    118 ; CHECK-LABEL: f13:
    119 ; CHECK: vlgvg %r2, %v24, 0
    120 ; CHECK: br %r14
    121   %ret = extractelement <2 x i64> %val, i32 0
    122   ret i64 %ret
    123 }
    124 
    125 ; Test v2i64 extraction of the last element.
    126 define i64 @f14(<2 x i64> %val) {
    127 ; CHECK-LABEL: f14:
    128 ; CHECK: vlgvg %r2, %v24, 1
    129 ; CHECK: br %r14
    130   %ret = extractelement <2 x i64> %val, i32 1
    131   ret i64 %ret
    132 }
    133 
    134 ; Test v2i64 extractions of an absurd element number.  This must compile
    135 ; but we don't care what it does.
    136 define i64 @f15(<2 x i64> %val) {
    137 ; CHECK-LABEL: f15:
    138 ; CHECK-NOT: vlgvg %r2, %v24, 100000
    139 ; CHECK: br %r14
    140   %ret = extractelement <2 x i64> %val, i32 100000
    141   ret i64 %ret
    142 }
    143 
    144 ; Test v2i64 extraction of a variable element.
    145 define i64 @f16(<2 x i64> %val, i32 %index) {
    146 ; CHECK-LABEL: f16:
    147 ; CHECK: vlgvg %r2, %v24, 0(%r2)
    148 ; CHECK: br %r14
    149   %ret = extractelement <2 x i64> %val, i32 %index
    150   ret i64 %ret
    151 }
    152 
    153 ; Test v4f32 extraction of element 0.
    154 define float @f17(<4 x float> %val) {
    155 ; CHECK-LABEL: f17:
    156 ; CHECK: vlr %v0, %v24
    157 ; CHECK: br %r14
    158   %ret = extractelement <4 x float> %val, i32 0
    159   ret float %ret
    160 }
    161 
    162 ; Test v4f32 extraction of element 1.
    163 define float @f18(<4 x float> %val) {
    164 ; CHECK-LABEL: f18:
    165 ; CHECK: vrepf %v0, %v24, 1
    166 ; CHECK: br %r14
    167   %ret = extractelement <4 x float> %val, i32 1
    168   ret float %ret
    169 }
    170 
    171 ; Test v4f32 extraction of element 2.
    172 define float @f19(<4 x float> %val) {
    173 ; CHECK-LABEL: f19:
    174 ; CHECK: vrepf %v0, %v24, 2
    175 ; CHECK: br %r14
    176   %ret = extractelement <4 x float> %val, i32 2
    177   ret float %ret
    178 }
    179 
    180 ; Test v4f32 extraction of element 3.
    181 define float @f20(<4 x float> %val) {
    182 ; CHECK-LABEL: f20:
    183 ; CHECK: vrepf %v0, %v24, 3
    184 ; CHECK: br %r14
    185   %ret = extractelement <4 x float> %val, i32 3
    186   ret float %ret
    187 }
    188 
    189 ; Test v4f32 extractions of an absurd element number.  This must compile
    190 ; but we don't care what it does.
    191 define float @f21(<4 x float> %val) {
    192   %ret = extractelement <4 x float> %val, i32 100000
    193   ret float %ret
    194 }
    195 
    196 ; Test v4f32 extraction of a variable element.
    197 define float @f22(<4 x float> %val, i32 %index) {
    198 ; CHECK-LABEL: f22:
    199 ; CHECK: vlgvf [[REG:%r[0-5]]], %v24, 0(%r2)
    200 ; CHECK: vlvgf %v0, [[REG]], 0
    201 ; CHECK: br %r14
    202   %ret = extractelement <4 x float> %val, i32 %index
    203   ret float %ret
    204 }
    205 
    206 ; Test v2f64 extraction of the first element.
    207 define double @f23(<2 x double> %val) {
    208 ; CHECK-LABEL: f23:
    209 ; CHECK: vlr %v0, %v24
    210 ; CHECK: br %r14
    211   %ret = extractelement <2 x double> %val, i32 0
    212   ret double %ret
    213 }
    214 
    215 ; Test v2f64 extraction of the last element.
    216 define double @f24(<2 x double> %val) {
    217 ; CHECK-LABEL: f24:
    218 ; CHECK: vrepg %v0, %v24, 1
    219 ; CHECK: br %r14
    220   %ret = extractelement <2 x double> %val, i32 1
    221   ret double %ret
    222 }
    223 
    224 ; Test v2f64 extractions of an absurd element number.  This must compile
    225 ; but we don't care what it does.
    226 define double @f25(<2 x double> %val) {
    227   %ret = extractelement <2 x double> %val, i32 100000
    228   ret double %ret
    229 }
    230 
    231 ; Test v2f64 extraction of a variable element.
    232 define double @f26(<2 x double> %val, i32 %index) {
    233 ; CHECK-LABEL: f26:
    234 ; CHECK: vlgvg [[REG:%r[0-5]]], %v24, 0(%r2)
    235 ; CHECK: ldgr %f0, [[REG]]
    236 ; CHECK: br %r14
    237   %ret = extractelement <2 x double> %val, i32 %index
    238   ret double %ret
    239 }
    240 
    241 ; Test v16i8 extraction of a variable element with an offset.
    242 define i8 @f27(<16 x i8> %val, i32 %index) {
    243 ; CHECK-LABEL: f27:
    244 ; CHECK: vlgvb %r2, %v24, 1(%r2)
    245 ; CHECK: br %r14
    246   %add = add i32 %index, 1
    247   %ret = extractelement <16 x i8> %val, i32 %add
    248   ret i8 %ret
    249 }
    250