Home | History | Annotate | Download | only in SystemZ
      1 ; Test data prefetching.
      2 ;
      3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
      4 
      5 declare void @llvm.prefetch(i8*, i32, i32, i32)
      6 
      7 @g = global [4096 x i8] zeroinitializer
      8 
      9 ; Check that instruction read prefetches are ignored.
     10 define void @f1(i8 *%ptr) {
     11 ; CHECK-LABEL: f1:
     12 ; CHECK-NOT: %r2
     13 ; CHECK: br %r14
     14   call void @llvm.prefetch(i8 *%ptr, i32 0, i32 0, i32 0)
     15   ret void
     16 }
     17 
     18 ; Check that instruction write prefetches are ignored.
     19 define void @f2(i8 *%ptr) {
     20 ; CHECK-LABEL: f2:
     21 ; CHECK-NOT: %r2
     22 ; CHECK: br %r14
     23   call void @llvm.prefetch(i8 *%ptr, i32 1, i32 0, i32 0)
     24   ret void
     25 }
     26 
     27 ; Check data read prefetches.
     28 define void @f3(i8 *%ptr) {
     29 ; CHECK-LABEL: f3:
     30 ; CHECK: pfd 1, 0(%r2)
     31 ; CHECK: br %r14
     32   call void @llvm.prefetch(i8 *%ptr, i32 0, i32 0, i32 1)
     33   ret void
     34 }
     35 
     36 ; Check data write prefetches.
     37 define void @f4(i8 *%ptr) {
     38 ; CHECK-LABEL: f4:
     39 ; CHECK: pfd 2, 0(%r2)
     40 ; CHECK: br %r14
     41   call void @llvm.prefetch(i8 *%ptr, i32 1, i32 0, i32 1)
     42   ret void
     43 }
     44 
     45 ; Check an address at the negative end of the range.
     46 define void @f5(i8 *%base, i64 %index) {
     47 ; CHECK-LABEL: f5:
     48 ; CHECK: pfd 2, -524288({{%r2,%r3|%r3,%r2}})
     49 ; CHECK: br %r14
     50   %add = add i64 %index, -524288
     51   %ptr = getelementptr i8 *%base, i64 %add
     52   call void @llvm.prefetch(i8 *%ptr, i32 1, i32 0, i32 1)
     53   ret void
     54 }
     55 
     56 ; Check an address at the positive end of the range.
     57 define void @f6(i8 *%base, i64 %index) {
     58 ; CHECK-LABEL: f6:
     59 ; CHECK: pfd 2, 524287({{%r2,%r3|%r3,%r2}})
     60 ; CHECK: br %r14
     61   %add = add i64 %index, 524287
     62   %ptr = getelementptr i8 *%base, i64 %add
     63   call void @llvm.prefetch(i8 *%ptr, i32 1, i32 0, i32 1)
     64   ret void
     65 }
     66 
     67 ; Check that the next address up still compiles.
     68 define void @f7(i8 *%base, i64 %index) {
     69 ; CHECK-LABEL: f7:
     70 ; CHECK: 524288
     71 ; CHECK: pfd 2,
     72 ; CHECK: br %r14
     73   %add = add i64 %index, 524288
     74   %ptr = getelementptr i8 *%base, i64 %add
     75   call void @llvm.prefetch(i8 *%ptr, i32 1, i32 0, i32 1)
     76   ret void
     77 }
     78 
     79 ; Check pc-relative prefetches.
     80 define void @f8() {
     81 ; CHECK-LABEL: f8:
     82 ; CHECK: pfdrl 2, g
     83 ; CHECK: br %r14
     84   %ptr = getelementptr [4096 x i8] *@g, i64 0, i64 0
     85   call void @llvm.prefetch(i8 *%ptr, i32 1, i32 0, i32 1)
     86   ret void
     87 }
     88