Home | History | Annotate | Download | only in SystemZ
      1 ; Test memset in cases where the set value is variable.
      2 ;
      3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
      4 
      5 declare void @llvm.memset.p0i8.i32(i8 *nocapture, i8, i32, i32, i1) nounwind
      6 declare void @llvm.memset.p0i8.i64(i8 *nocapture, i8, i64, i32, i1) nounwind
      7 
      8 ; No bytes, i32 version.
      9 define void @f1(i8 *%dest, i8 %val) {
     10 ; CHECK-LABEL: f1:
     11 ; CHECK-NOT: %r2
     12 ; CHECK-NOT: %r3
     13 ; CHECK: br %r14
     14   call void @llvm.memset.p0i8.i32(i8 *%dest, i8 %val, i32 0, i32 1, i1 false)
     15   ret void
     16 }
     17 
     18 ; No bytes, i64 version.
     19 define void @f2(i8 *%dest, i8 %val) {
     20 ; CHECK-LABEL: f2:
     21 ; CHECK-NOT: %r2
     22 ; CHECK-NOT: %r3
     23 ; CHECK: br %r14
     24   call void @llvm.memset.p0i8.i64(i8 *%dest, i8 %val, i64 0, i32 1, i1 false)
     25   ret void
     26 }
     27 
     28 ; 1 byte, i32 version.
     29 define void @f3(i8 *%dest, i8 %val) {
     30 ; CHECK-LABEL: f3:
     31 ; CHECK: stc %r3, 0(%r2)
     32 ; CHECK: br %r14
     33   call void @llvm.memset.p0i8.i32(i8 *%dest, i8 %val, i32 1, i32 1, i1 false)
     34   ret void
     35 }
     36 
     37 ; 1 byte, i64 version.
     38 define void @f4(i8 *%dest, i8 %val) {
     39 ; CHECK-LABEL: f4:
     40 ; CHECK: stc %r3, 0(%r2)
     41 ; CHECK: br %r14
     42   call void @llvm.memset.p0i8.i64(i8 *%dest, i8 %val, i64 1, i32 1, i1 false)
     43   ret void
     44 }
     45 
     46 ; 2 bytes, i32 version.
     47 define void @f5(i8 *%dest, i8 %val) {
     48 ; CHECK-LABEL: f5:
     49 ; CHECK-DAG: stc %r3, 0(%r2)
     50 ; CHECK-DAG: stc %r3, 1(%r2)
     51 ; CHECK: br %r14
     52   call void @llvm.memset.p0i8.i32(i8 *%dest, i8 %val, i32 2, i32 1, i1 false)
     53   ret void
     54 }
     55 
     56 ; 2 bytes, i64 version.
     57 define void @f6(i8 *%dest, i8 %val) {
     58 ; CHECK-LABEL: f6:
     59 ; CHECK-DAG: stc %r3, 0(%r2)
     60 ; CHECK-DAG: stc %r3, 1(%r2)
     61 ; CHECK: br %r14
     62   call void @llvm.memset.p0i8.i64(i8 *%dest, i8 %val, i64 2, i32 1, i1 false)
     63   ret void
     64 }
     65 
     66 ; 3 bytes, i32 version.
     67 define void @f7(i8 *%dest, i8 %val) {
     68 ; CHECK-LABEL: f7:
     69 ; CHECK: stc %r3, 0(%r2)
     70 ; CHECK: mvc 1(2,%r2), 0(%r2)
     71 ; CHECK: br %r14
     72   call void @llvm.memset.p0i8.i32(i8 *%dest, i8 %val, i32 3, i32 1, i1 false)
     73   ret void
     74 }
     75 
     76 ; 3 bytes, i64 version.
     77 define void @f8(i8 *%dest, i8 %val) {
     78 ; CHECK-LABEL: f8:
     79 ; CHECK: stc %r3, 0(%r2)
     80 ; CHECK: mvc 1(2,%r2), 0(%r2)
     81 ; CHECK: br %r14
     82   call void @llvm.memset.p0i8.i64(i8 *%dest, i8 %val, i64 3, i32 1, i1 false)
     83   ret void
     84 }
     85 
     86 ; 257 bytes, i32 version.
     87 define void @f9(i8 *%dest, i8 %val) {
     88 ; CHECK-LABEL: f9:
     89 ; CHECK: stc %r3, 0(%r2)
     90 ; CHECK: mvc 1(256,%r2), 0(%r2)
     91 ; CHECK: br %r14
     92   call void @llvm.memset.p0i8.i32(i8 *%dest, i8 %val, i32 257, i32 1, i1 false)
     93   ret void
     94 }
     95 
     96 ; 257 bytes, i64 version.
     97 define void @f10(i8 *%dest, i8 %val) {
     98 ; CHECK-LABEL: f10:
     99 ; CHECK: stc %r3, 0(%r2)
    100 ; CHECK: mvc 1(256,%r2), 0(%r2)
    101 ; CHECK: br %r14
    102   call void @llvm.memset.p0i8.i64(i8 *%dest, i8 %val, i64 257, i32 1, i1 false)
    103   ret void
    104 }
    105 
    106 ; 258 bytes, i32 version.  258 bytes is too big for a single MVC.
    107 ; For now expect none, so that the test fails and gets updated when
    108 ; large copies are implemented.
    109 define void @f11(i8 *%dest, i8 %val) {
    110 ; CHECK-LABEL: f11:
    111 ; CHECK-NOT: mvc
    112 ; CHECK: br %r14
    113   call void @llvm.memset.p0i8.i32(i8 *%dest, i8 %val, i32 258, i32 1, i1 false)
    114   ret void
    115 }
    116 
    117 ; 258 bytes, i64 version, with the same comments as above.
    118 define void @f12(i8 *%dest, i8 %val) {
    119 ; CHECK-LABEL: f12:
    120 ; CHECK-NOT: mvc
    121 ; CHECK: br %r14
    122   call void @llvm.memset.p0i8.i64(i8 *%dest, i8 %val, i64 258, i32 1, i1 false)
    123   ret void
    124 }
    125