Home | History | Annotate | Download | only in AArch64
      1 ; RUN: llc < %s -march=arm64 -aarch64-redzone | FileCheck %s
      2 
      3 define void @store64(i64** nocapture %out, i64 %index, i64 %spacing) nounwind noinline ssp {
      4 ; CHECK-LABEL: store64:
      5 ; CHECK: str x{{[0-9+]}}, [x{{[0-9+]}}], #8
      6 ; CHECK: ret
      7   %tmp = load i64*, i64** %out, align 8
      8   %incdec.ptr = getelementptr inbounds i64, i64* %tmp, i64 1
      9   store i64 %spacing, i64* %tmp, align 4
     10   store i64* %incdec.ptr, i64** %out, align 8
     11   ret void
     12 }
     13 
     14 define void @store32(i32** nocapture %out, i32 %index, i32 %spacing) nounwind noinline ssp {
     15 ; CHECK-LABEL: store32:
     16 ; CHECK: str w{{[0-9+]}}, [x{{[0-9+]}}], #4
     17 ; CHECK: ret
     18   %tmp = load i32*, i32** %out, align 8
     19   %incdec.ptr = getelementptr inbounds i32, i32* %tmp, i64 1
     20   store i32 %spacing, i32* %tmp, align 4
     21   store i32* %incdec.ptr, i32** %out, align 8
     22   ret void
     23 }
     24 
     25 define void @store16(i16** nocapture %out, i16 %index, i16 %spacing) nounwind noinline ssp {
     26 ; CHECK-LABEL: store16:
     27 ; CHECK: strh w{{[0-9+]}}, [x{{[0-9+]}}], #2
     28 ; CHECK: ret
     29   %tmp = load i16*, i16** %out, align 8
     30   %incdec.ptr = getelementptr inbounds i16, i16* %tmp, i64 1
     31   store i16 %spacing, i16* %tmp, align 4
     32   store i16* %incdec.ptr, i16** %out, align 8
     33   ret void
     34 }
     35 
     36 define void @store8(i8** nocapture %out, i8 %index, i8 %spacing) nounwind noinline ssp {
     37 ; CHECK-LABEL: store8:
     38 ; CHECK: strb w{{[0-9+]}}, [x{{[0-9+]}}], #1
     39 ; CHECK: ret
     40   %tmp = load i8*, i8** %out, align 8
     41   %incdec.ptr = getelementptr inbounds i8, i8* %tmp, i64 1
     42   store i8 %spacing, i8* %tmp, align 4
     43   store i8* %incdec.ptr, i8** %out, align 8
     44   ret void
     45 }
     46 
     47 define void @truncst64to32(i32** nocapture %out, i32 %index, i64 %spacing) nounwind noinline ssp {
     48 ; CHECK-LABEL: truncst64to32:
     49 ; CHECK: str w{{[0-9+]}}, [x{{[0-9+]}}], #4
     50 ; CHECK: ret
     51   %tmp = load i32*, i32** %out, align 8
     52   %incdec.ptr = getelementptr inbounds i32, i32* %tmp, i64 1
     53   %trunc = trunc i64 %spacing to i32
     54   store i32 %trunc, i32* %tmp, align 4
     55   store i32* %incdec.ptr, i32** %out, align 8
     56   ret void
     57 }
     58 
     59 define void @truncst64to16(i16** nocapture %out, i16 %index, i64 %spacing) nounwind noinline ssp {
     60 ; CHECK-LABEL: truncst64to16:
     61 ; CHECK: strh w{{[0-9+]}}, [x{{[0-9+]}}], #2
     62 ; CHECK: ret
     63   %tmp = load i16*, i16** %out, align 8
     64   %incdec.ptr = getelementptr inbounds i16, i16* %tmp, i64 1
     65   %trunc = trunc i64 %spacing to i16
     66   store i16 %trunc, i16* %tmp, align 4
     67   store i16* %incdec.ptr, i16** %out, align 8
     68   ret void
     69 }
     70 
     71 define void @truncst64to8(i8** nocapture %out, i8 %index, i64 %spacing) nounwind noinline ssp {
     72 ; CHECK-LABEL: truncst64to8:
     73 ; CHECK: strb w{{[0-9+]}}, [x{{[0-9+]}}], #1
     74 ; CHECK: ret
     75   %tmp = load i8*, i8** %out, align 8
     76   %incdec.ptr = getelementptr inbounds i8, i8* %tmp, i64 1
     77   %trunc = trunc i64 %spacing to i8
     78   store i8 %trunc, i8* %tmp, align 4
     79   store i8* %incdec.ptr, i8** %out, align 8
     80   ret void
     81 }
     82 
     83 
     84 define void @storef16(half** %out, half %index, half %spacing) nounwind {
     85 ; CHECK-LABEL: storef16:
     86 ; CHECK: str h{{[0-9+]}}, [x{{[0-9+]}}], #2
     87 ; CHECK: ret
     88   %tmp = load half*, half** %out, align 2
     89   %incdec.ptr = getelementptr inbounds half, half* %tmp, i64 1
     90   store half %spacing, half* %tmp, align 2
     91   store half* %incdec.ptr, half** %out, align 2
     92   ret void
     93 }
     94 
     95 define void @storef32(float** nocapture %out, float %index, float %spacing) nounwind noinline ssp {
     96 ; CHECK-LABEL: storef32:
     97 ; CHECK: str s{{[0-9+]}}, [x{{[0-9+]}}], #4
     98 ; CHECK: ret
     99   %tmp = load float*, float** %out, align 8
    100   %incdec.ptr = getelementptr inbounds float, float* %tmp, i64 1
    101   store float %spacing, float* %tmp, align 4
    102   store float* %incdec.ptr, float** %out, align 8
    103   ret void
    104 }
    105 
    106 define void @storef64(double** nocapture %out, double %index, double %spacing) nounwind noinline ssp {
    107 ; CHECK-LABEL: storef64:
    108 ; CHECK: str d{{[0-9+]}}, [x{{[0-9+]}}], #8
    109 ; CHECK: ret
    110   %tmp = load double*, double** %out, align 8
    111   %incdec.ptr = getelementptr inbounds double, double* %tmp, i64 1
    112   store double %spacing, double* %tmp, align 4
    113   store double* %incdec.ptr, double** %out, align 8
    114   ret void
    115 }
    116 
    117 define double * @pref64(double** nocapture %out, double %spacing) nounwind noinline ssp {
    118 ; CHECK-LABEL: pref64:
    119 ; CHECK: ldr     x0, [x0]
    120 ; CHECK-NEXT: str     d0, [x0, #32]!
    121 ; CHECK-NEXT: ret
    122   %tmp = load double*, double** %out, align 8
    123   %ptr = getelementptr inbounds double, double* %tmp, i64 4
    124   store double %spacing, double* %ptr, align 4
    125   ret double *%ptr
    126 }
    127 
    128 define float * @pref32(float** nocapture %out, float %spacing) nounwind noinline ssp {
    129 ; CHECK-LABEL: pref32:
    130 ; CHECK: ldr     x0, [x0]
    131 ; CHECK-NEXT: str     s0, [x0, #12]!
    132 ; CHECK-NEXT: ret
    133   %tmp = load float*, float** %out, align 8
    134   %ptr = getelementptr inbounds float, float* %tmp, i64 3
    135   store float %spacing, float* %ptr, align 4
    136   ret float *%ptr
    137 }
    138 
    139 define half* @pref16(half** %out, half %spacing) nounwind {
    140 ; CHECK-LABEL: pref16:
    141 ; CHECK: ldr x0, [x0]
    142 ; CHECK-NEXT: str h0, [x0, #6]!
    143 ; CHECK-NEXT: ret
    144   %tmp = load half*, half** %out, align 2
    145   %ptr = getelementptr inbounds half, half* %tmp, i64 3
    146   store half %spacing, half* %ptr, align 2
    147   ret half *%ptr
    148 }
    149 
    150 define i64 * @pre64(i64** nocapture %out, i64 %spacing) nounwind noinline ssp {
    151 ; CHECK-LABEL: pre64:
    152 ; CHECK: ldr     x0, [x0]
    153 ; CHECK-NEXT: str     x1, [x0, #16]!
    154 ; CHECK-NEXT: ret
    155   %tmp = load i64*, i64** %out, align 8
    156   %ptr = getelementptr inbounds i64, i64* %tmp, i64 2
    157   store i64 %spacing, i64* %ptr, align 4
    158   ret i64 *%ptr
    159 }
    160 
    161 define i32 * @pre32(i32** nocapture %out, i32 %spacing) nounwind noinline ssp {
    162 ; CHECK-LABEL: pre32:
    163 ; CHECK: ldr     x0, [x0]
    164 ; CHECK-NEXT: str     w1, [x0, #8]!
    165 ; CHECK-NEXT: ret
    166   %tmp = load i32*, i32** %out, align 8
    167   %ptr = getelementptr inbounds i32, i32* %tmp, i64 2
    168   store i32 %spacing, i32* %ptr, align 4
    169   ret i32 *%ptr
    170 }
    171 
    172 define i16 * @pre16(i16** nocapture %out, i16 %spacing) nounwind noinline ssp {
    173 ; CHECK-LABEL: pre16:
    174 ; CHECK: ldr     x0, [x0]
    175 ; CHECK-NEXT: strh    w1, [x0, #4]!
    176 ; CHECK-NEXT: ret
    177   %tmp = load i16*, i16** %out, align 8
    178   %ptr = getelementptr inbounds i16, i16* %tmp, i64 2
    179   store i16 %spacing, i16* %ptr, align 4
    180   ret i16 *%ptr
    181 }
    182 
    183 define i8 * @pre8(i8** nocapture %out, i8 %spacing) nounwind noinline ssp {
    184 ; CHECK-LABEL: pre8:
    185 ; CHECK: ldr     x0, [x0]
    186 ; CHECK-NEXT: strb    w1, [x0, #2]!
    187 ; CHECK-NEXT: ret
    188   %tmp = load i8*, i8** %out, align 8
    189   %ptr = getelementptr inbounds i8, i8* %tmp, i64 2
    190   store i8 %spacing, i8* %ptr, align 4
    191   ret i8 *%ptr
    192 }
    193 
    194 define i32 * @pretrunc64to32(i32** nocapture %out, i64 %spacing) nounwind noinline ssp {
    195 ; CHECK-LABEL: pretrunc64to32:
    196 ; CHECK: ldr     x0, [x0]
    197 ; CHECK-NEXT: str     w1, [x0, #8]!
    198 ; CHECK-NEXT: ret
    199   %tmp = load i32*, i32** %out, align 8
    200   %ptr = getelementptr inbounds i32, i32* %tmp, i64 2
    201   %trunc = trunc i64 %spacing to i32
    202   store i32 %trunc, i32* %ptr, align 4
    203   ret i32 *%ptr
    204 }
    205 
    206 define i16 * @pretrunc64to16(i16** nocapture %out, i64 %spacing) nounwind noinline ssp {
    207 ; CHECK-LABEL: pretrunc64to16:
    208 ; CHECK: ldr     x0, [x0]
    209 ; CHECK-NEXT: strh    w1, [x0, #4]!
    210 ; CHECK-NEXT: ret
    211   %tmp = load i16*, i16** %out, align 8
    212   %ptr = getelementptr inbounds i16, i16* %tmp, i64 2
    213   %trunc = trunc i64 %spacing to i16
    214   store i16 %trunc, i16* %ptr, align 4
    215   ret i16 *%ptr
    216 }
    217 
    218 define i8 * @pretrunc64to8(i8** nocapture %out, i64 %spacing) nounwind noinline ssp {
    219 ; CHECK-LABEL: pretrunc64to8:
    220 ; CHECK: ldr     x0, [x0]
    221 ; CHECK-NEXT: strb    w1, [x0, #2]!
    222 ; CHECK-NEXT: ret
    223   %tmp = load i8*, i8** %out, align 8
    224   %ptr = getelementptr inbounds i8, i8* %tmp, i64 2
    225   %trunc = trunc i64 %spacing to i8
    226   store i8 %trunc, i8* %ptr, align 4
    227   ret i8 *%ptr
    228 }
    229 
    230 ;-----
    231 ; Pre-indexed loads
    232 ;-----
    233 define double* @preidxf64(double* %src, double* %out) {
    234 ; CHECK-LABEL: preidxf64:
    235 ; CHECK: ldr     d0, [x0, #8]!
    236 ; CHECK: str     d0, [x1]
    237 ; CHECK: ret
    238   %ptr = getelementptr inbounds double, double* %src, i64 1
    239   %tmp = load double, double* %ptr, align 4
    240   store double %tmp, double* %out, align 4
    241   ret double* %ptr
    242 }
    243 
    244 define float* @preidxf32(float* %src, float* %out) {
    245 ; CHECK-LABEL: preidxf32:
    246 ; CHECK: ldr     s0, [x0, #4]!
    247 ; CHECK: str     s0, [x1]
    248 ; CHECK: ret
    249   %ptr = getelementptr inbounds float, float* %src, i64 1
    250   %tmp = load float, float* %ptr, align 4
    251   store float %tmp, float* %out, align 4
    252   ret float* %ptr
    253 }
    254 
    255 define half* @preidxf16(half* %src, half* %out) {
    256 ; CHECK-LABEL: preidxf16:
    257 ; CHECK: ldr     h0, [x0, #2]!
    258 ; CHECK: str     h0, [x1]
    259 ; CHECK: ret
    260   %ptr = getelementptr inbounds half, half* %src, i64 1
    261   %tmp = load half, half* %ptr, align 2
    262   store half %tmp, half* %out, align 2
    263   ret half* %ptr
    264 }
    265 
    266 define i64* @preidx64(i64* %src, i64* %out) {
    267 ; CHECK-LABEL: preidx64:
    268 ; CHECK: ldr     x[[REG:[0-9]+]], [x0, #8]!
    269 ; CHECK: str     x[[REG]], [x1]
    270 ; CHECK: ret
    271   %ptr = getelementptr inbounds i64, i64* %src, i64 1
    272   %tmp = load i64, i64* %ptr, align 4
    273   store i64 %tmp, i64* %out, align 4
    274   ret i64* %ptr
    275 }
    276 
    277 define i32* @preidx32(i32* %src, i32* %out) {
    278 ; CHECK: ldr     w[[REG:[0-9]+]], [x0, #4]!
    279 ; CHECK: str     w[[REG]], [x1]
    280 ; CHECK: ret
    281   %ptr = getelementptr inbounds i32, i32* %src, i64 1
    282   %tmp = load i32, i32* %ptr, align 4
    283   store i32 %tmp, i32* %out, align 4
    284   ret i32* %ptr
    285 }
    286 
    287 define i16* @preidx16zext32(i16* %src, i32* %out) {
    288 ; CHECK: ldrh    w[[REG:[0-9]+]], [x0, #2]!
    289 ; CHECK: str     w[[REG]], [x1]
    290 ; CHECK: ret
    291   %ptr = getelementptr inbounds i16, i16* %src, i64 1
    292   %tmp = load i16, i16* %ptr, align 4
    293   %ext = zext i16 %tmp to i32
    294   store i32 %ext, i32* %out, align 4
    295   ret i16* %ptr
    296 }
    297 
    298 define i16* @preidx16zext64(i16* %src, i64* %out) {
    299 ; CHECK: ldrh    w[[REG:[0-9]+]], [x0, #2]!
    300 ; CHECK: str     x[[REG]], [x1]
    301 ; CHECK: ret
    302   %ptr = getelementptr inbounds i16, i16* %src, i64 1
    303   %tmp = load i16, i16* %ptr, align 4
    304   %ext = zext i16 %tmp to i64
    305   store i64 %ext, i64* %out, align 4
    306   ret i16* %ptr
    307 }
    308 
    309 define i8* @preidx8zext32(i8* %src, i32* %out) {
    310 ; CHECK: ldrb    w[[REG:[0-9]+]], [x0, #1]!
    311 ; CHECK: str     w[[REG]], [x1]
    312 ; CHECK: ret
    313   %ptr = getelementptr inbounds i8, i8* %src, i64 1
    314   %tmp = load i8, i8* %ptr, align 4
    315   %ext = zext i8 %tmp to i32
    316   store i32 %ext, i32* %out, align 4
    317   ret i8* %ptr
    318 }
    319 
    320 define i8* @preidx8zext64(i8* %src, i64* %out) {
    321 ; CHECK: ldrb    w[[REG:[0-9]+]], [x0, #1]!
    322 ; CHECK: str     x[[REG]], [x1]
    323 ; CHECK: ret
    324   %ptr = getelementptr inbounds i8, i8* %src, i64 1
    325   %tmp = load i8, i8* %ptr, align 4
    326   %ext = zext i8 %tmp to i64
    327   store i64 %ext, i64* %out, align 4
    328   ret i8* %ptr
    329 }
    330 
    331 define i32* @preidx32sext64(i32* %src, i64* %out) {
    332 ; CHECK: ldrsw   x[[REG:[0-9]+]], [x0, #4]!
    333 ; CHECK: str     x[[REG]], [x1]
    334 ; CHECK: ret
    335   %ptr = getelementptr inbounds i32, i32* %src, i64 1
    336   %tmp = load i32, i32* %ptr, align 4
    337   %ext = sext i32 %tmp to i64
    338   store i64 %ext, i64* %out, align 8
    339   ret i32* %ptr
    340 }
    341 
    342 define i16* @preidx16sext32(i16* %src, i32* %out) {
    343 ; CHECK: ldrsh   w[[REG:[0-9]+]], [x0, #2]!
    344 ; CHECK: str     w[[REG]], [x1]
    345 ; CHECK: ret
    346   %ptr = getelementptr inbounds i16, i16* %src, i64 1
    347   %tmp = load i16, i16* %ptr, align 4
    348   %ext = sext i16 %tmp to i32
    349   store i32 %ext, i32* %out, align 4
    350   ret i16* %ptr
    351 }
    352 
    353 define i16* @preidx16sext64(i16* %src, i64* %out) {
    354 ; CHECK: ldrsh   x[[REG:[0-9]+]], [x0, #2]!
    355 ; CHECK: str     x[[REG]], [x1]
    356 ; CHECK: ret
    357   %ptr = getelementptr inbounds i16, i16* %src, i64 1
    358   %tmp = load i16, i16* %ptr, align 4
    359   %ext = sext i16 %tmp to i64
    360   store i64 %ext, i64* %out, align 4
    361   ret i16* %ptr
    362 }
    363 
    364 define i8* @preidx8sext32(i8* %src, i32* %out) {
    365 ; CHECK: ldrsb   w[[REG:[0-9]+]], [x0, #1]!
    366 ; CHECK: str     w[[REG]], [x1]
    367 ; CHECK: ret
    368   %ptr = getelementptr inbounds i8, i8* %src, i64 1
    369   %tmp = load i8, i8* %ptr, align 4
    370   %ext = sext i8 %tmp to i32
    371   store i32 %ext, i32* %out, align 4
    372   ret i8* %ptr
    373 }
    374 
    375 define i8* @preidx8sext64(i8* %src, i64* %out) {
    376 ; CHECK: ldrsb   x[[REG:[0-9]+]], [x0, #1]!
    377 ; CHECK: str     x[[REG]], [x1]
    378 ; CHECK: ret
    379   %ptr = getelementptr inbounds i8, i8* %src, i64 1
    380   %tmp = load i8, i8* %ptr, align 4
    381   %ext = sext i8 %tmp to i64
    382   store i64 %ext, i64* %out, align 4
    383   ret i8* %ptr
    384 }
    385 
    386 ; This test checks if illegal post-index is generated
    387 
    388 define i64* @postidx_clobber(i64* %addr) nounwind noinline ssp {
    389 ; CHECK-LABEL: postidx_clobber:
    390 ; CHECK-NOT: str     x0, [x0], #8
    391 ; ret
    392  %paddr = bitcast i64* %addr to i64**
    393  store i64* %addr, i64** %paddr
    394  %newaddr = getelementptr i64, i64* %addr, i32 1
    395  ret i64* %newaddr
    396 }
    397