Home | History | Annotate | Download | only in X86
      1 ; REQUIRES: asserts
      2 ; RUN: opt -loop-vectorize -S -mcpu=skx --debug-only=loop-vectorize < %s 2>&1| FileCheck %s
      3 
      4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
      5 target triple = "x86_64-unknown-linux-gnu"
      6 
      7 @A = global [10240 x i32] zeroinitializer, align 16
      8 @B = global [10240 x i32] zeroinitializer, align 16
      9 
     10 ; Function Attrs: nounwind uwtable
     11 define void @load_int_stride2() {
     12 ;CHECK-LABEL: load_int_stride2
     13 ;CHECK: Found an estimated cost of 1 for VF 1 For instruction:   %1 = load
     14 ;CHECK: Found an estimated cost of 1 for VF 2 For instruction:   %1 = load
     15 ;CHECK: Found an estimated cost of 1 for VF 4 For instruction:   %1 = load
     16 ;CHECK: Found an estimated cost of 1 for VF 8 For instruction:   %1 = load
     17 ;CHECK: Found an estimated cost of 2 for VF 16 For instruction:  %1 = load
     18 entry:
     19   br label %for.body
     20 
     21 for.body:                                         ; preds = %for.body, %entry
     22   %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
     23   %0 = shl nsw i64 %indvars.iv, 1
     24   %arrayidx = getelementptr inbounds [10240 x i32], [10240 x i32]* @A, i64 0, i64 %0
     25   %1 = load i32, i32* %arrayidx, align 4
     26   %arrayidx2 = getelementptr inbounds [10240 x i32], [10240 x i32]* @B, i64 0, i64 %indvars.iv
     27   store i32 %1, i32* %arrayidx2, align 2
     28   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
     29   %exitcond = icmp eq i64 %indvars.iv.next, 1024
     30   br i1 %exitcond, label %for.end, label %for.body
     31 
     32 for.end:                                          ; preds = %for.body
     33   ret void
     34 }
     35 
     36 define void @load_int_stride3() {
     37 ;CHECK-LABEL: load_int_stride3
     38 ;CHECK: Found an estimated cost of 1 for VF 1 For instruction:   %1 = load
     39 ;CHECK: Found an estimated cost of 1 for VF 2 For instruction:   %1 = load
     40 ;CHECK: Found an estimated cost of 1 for VF 4 For instruction:   %1 = load
     41 ;CHECK: Found an estimated cost of 2 for VF 8 For instruction:   %1 = load
     42 ;CHECK: Found an estimated cost of 3 for VF 16 For instruction:  %1 = load
     43 entry:
     44   br label %for.body
     45 
     46 for.body:                                         ; preds = %for.body, %entry
     47   %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
     48   %0 = mul nsw i64 %indvars.iv, 3
     49   %arrayidx = getelementptr inbounds [10240 x i32], [10240 x i32]* @A, i64 0, i64 %0
     50   %1 = load i32, i32* %arrayidx, align 4
     51   %arrayidx2 = getelementptr inbounds [10240 x i32], [10240 x i32]* @B, i64 0, i64 %indvars.iv
     52   store i32 %1, i32* %arrayidx2, align 2
     53   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
     54   %exitcond = icmp eq i64 %indvars.iv.next, 1024
     55   br i1 %exitcond, label %for.end, label %for.body
     56 
     57 for.end:                                          ; preds = %for.body
     58   ret void
     59 }
     60 
     61 define void @load_int_stride4() {
     62 ;CHECK-LABEL: load_int_stride4
     63 ;CHECK: Found an estimated cost of 1 for VF 1 For instruction:   %1 = load
     64 ;CHECK: Found an estimated cost of 1 for VF 2 For instruction:   %1 = load
     65 ;CHECK: Found an estimated cost of 1 for VF 4 For instruction:   %1 = load
     66 ;CHECK: Found an estimated cost of 2 for VF 8 For instruction:   %1 = load
     67 ;CHECK: Found an estimated cost of 5 for VF 16 For instruction:  %1 = load
     68 entry:
     69   br label %for.body
     70 
     71 for.body:                                         ; preds = %for.body, %entry
     72   %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
     73   %0 = shl nsw i64 %indvars.iv, 2
     74   %arrayidx = getelementptr inbounds [10240 x i32], [10240 x i32]* @A, i64 0, i64 %0
     75   %1 = load i32, i32* %arrayidx, align 4
     76   %arrayidx2 = getelementptr inbounds [10240 x i32], [10240 x i32]* @B, i64 0, i64 %indvars.iv
     77   store i32 %1, i32* %arrayidx2, align 2
     78   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
     79   %exitcond = icmp eq i64 %indvars.iv.next, 1024
     80   br i1 %exitcond, label %for.end, label %for.body
     81 
     82 for.end:                                          ; preds = %for.body
     83   ret void
     84 }
     85 
     86 define void @load_int_stride5() {
     87 ;CHECK-LABEL: load_int_stride5
     88 ;CHECK: Found an estimated cost of 1 for VF 1 For instruction:   %1 = load
     89 ;CHECK: Found an estimated cost of 1 for VF 2 For instruction:   %1 = load
     90 ;CHECK: Found an estimated cost of 2 for VF 4 For instruction:   %1 = load
     91 ;CHECK: Found an estimated cost of 3 for VF 8 For instruction:   %1 = load
     92 ;CHECK: Found an estimated cost of 6 for VF 16 For instruction:  %1 = load
     93 entry:
     94   br label %for.body
     95 
     96 for.body:                                         ; preds = %for.body, %entry
     97   %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
     98   %0 = mul nsw i64 %indvars.iv, 5
     99   %arrayidx = getelementptr inbounds [10240 x i32], [10240 x i32]* @A, i64 0, i64 %0
    100   %1 = load i32, i32* %arrayidx, align 4
    101   %arrayidx2 = getelementptr inbounds [10240 x i32], [10240 x i32]* @B, i64 0, i64 %indvars.iv
    102   store i32 %1, i32* %arrayidx2, align 2
    103   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
    104   %exitcond = icmp eq i64 %indvars.iv.next, 1024
    105   br i1 %exitcond, label %for.end, label %for.body
    106 
    107 for.end:                                          ; preds = %for.body
    108   ret void
    109 }
    110 
    111