2 ; RUN: opt -passes=loop-vectorize -S -mattr=avx512f --debug-only=loop-vectorize < %s 2>&1| FileCheck %s
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 @A = global [10240 x i32] zeroinitializer, align 16
8 @B = global [10240 x i32] zeroinitializer, align 16
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
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], ptr @A, i64 0, i64 %0
25 %1 = load i32, ptr %arrayidx, align 4
26 %arrayidx2 = getelementptr inbounds [10240 x i32], ptr @B, i64 0, i64 %indvars.iv
27 store i32 %1, ptr %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
32 for.end: ; preds = %for.body
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
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], ptr @A, i64 0, i64 %0
50 %1 = load i32, ptr %arrayidx, align 4
51 %arrayidx2 = getelementptr inbounds [10240 x i32], ptr @B, i64 0, i64 %indvars.iv
52 store i32 %1, ptr %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
57 for.end: ; preds = %for.body
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
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], ptr @A, i64 0, i64 %0
75 %1 = load i32, ptr %arrayidx, align 4
76 %arrayidx2 = getelementptr inbounds [10240 x i32], ptr @B, i64 0, i64 %indvars.iv
77 store i32 %1, ptr %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
82 for.end: ; preds = %for.body
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
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], ptr @A, i64 0, i64 %0
100 %1 = load i32, ptr %arrayidx, align 4
101 %arrayidx2 = getelementptr inbounds [10240 x i32], ptr @B, i64 0, i64 %indvars.iv
102 store i32 %1, ptr %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
107 for.end: ; preds = %for.body