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 i64] zeroinitializer, align 16
8 @B = global [10240 x i64] zeroinitializer, align 16
10 ; Function Attrs: nounwind uwtable
11 define void @load_i64_stride2() {
12 ;CHECK-LABEL: load_i64_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 2 for VF 8 For instruction: %1 = load
20 for.body: ; preds = %for.body, %entry
21 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
22 %0 = shl nsw i64 %indvars.iv, 1
23 %arrayidx = getelementptr inbounds [10240 x i64], ptr @A, i64 0, i64 %0
24 %1 = load i64, ptr %arrayidx, align 16
25 %arrayidx2 = getelementptr inbounds [10240 x i64], ptr @B, i64 0, i64 %indvars.iv
26 store i64 %1, ptr %arrayidx2, align 8
27 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
28 %exitcond = icmp eq i64 %indvars.iv.next, 1024
29 br i1 %exitcond, label %for.end, label %for.body
31 for.end: ; preds = %for.body
35 define void @load_i64_stride3() {
36 ;CHECK-LABEL: load_i64_stride3
37 ;CHECK: Found an estimated cost of 1 for VF 1 For instruction: %1 = load
38 ;CHECK: Found an estimated cost of 1 for VF 2 For instruction: %1 = load
39 ;CHECK: Found an estimated cost of 2 for VF 4 For instruction: %1 = load
40 ;CHECK: Found an estimated cost of 3 for VF 8 For instruction: %1 = load
44 for.body: ; preds = %for.body, %entry
45 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
46 %0 = mul nsw i64 %indvars.iv, 3
47 %arrayidx = getelementptr inbounds [10240 x i64], ptr @A, i64 0, i64 %0
48 %1 = load i64, ptr %arrayidx, align 16
49 %arrayidx2 = getelementptr inbounds [10240 x i64], ptr @B, i64 0, i64 %indvars.iv
50 store i64 %1, ptr %arrayidx2, align 8
51 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
52 %exitcond = icmp eq i64 %indvars.iv.next, 1024
53 br i1 %exitcond, label %for.end, label %for.body
55 for.end: ; preds = %for.body
59 define void @load_i64_stride4() {
60 ;CHECK-LABEL: load_i64_stride4
61 ;CHECK: Found an estimated cost of 1 for VF 1 For instruction: %1 = load
62 ;CHECK: Found an estimated cost of 1 for VF 2 For instruction: %1 = load
63 ;CHECK: Found an estimated cost of 2 for VF 4 For instruction: %1 = load
64 ;CHECK: Found an estimated cost of 5 for VF 8 For instruction: %1 = load
68 for.body: ; preds = %for.body, %entry
69 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
70 %0 = mul nsw i64 %indvars.iv, 4
71 %arrayidx = getelementptr inbounds [10240 x i64], ptr @A, i64 0, i64 %0
72 %1 = load i64, ptr %arrayidx, align 16
73 %arrayidx2 = getelementptr inbounds [10240 x i64], ptr @B, i64 0, i64 %indvars.iv
74 store i64 %1, ptr %arrayidx2, align 8
75 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
76 %exitcond = icmp eq i64 %indvars.iv.next, 1024
77 br i1 %exitcond, label %for.end, label %for.body
79 for.end: ; preds = %for.body