2 ; RUN: opt -passes=loop-vectorize -S -mattr=avx512bw --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 i8] zeroinitializer, align 16
8 @B = global [10240 x i8] zeroinitializer, align 16
10 ; Function Attrs: nounwind uwtable
11 define void @load_i8_stride2() {
12 ;CHECK-LABEL: load_i8_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 4 for VF 16 For instruction: %1 = load
18 ;CHECK: Found an estimated cost of 8 for VF 32 For instruction: %1 = load
19 ;CHECK: Found an estimated cost of 20 for VF 64 For instruction: %1 = load
23 for.body: ; preds = %for.body, %entry
24 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
25 %0 = shl nsw i64 %indvars.iv, 1
26 %arrayidx = getelementptr inbounds [10240 x i8], ptr @A, i64 0, i64 %0
27 %1 = load i8, ptr %arrayidx, align 2
28 %arrayidx2 = getelementptr inbounds [10240 x i8], ptr @B, i64 0, i64 %indvars.iv
29 store i8 %1, ptr %arrayidx2, align 1
30 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
31 %exitcond = icmp eq i64 %indvars.iv.next, 1024
32 br i1 %exitcond, label %for.end, label %for.body
34 for.end: ; preds = %for.body
38 define void @load_i8_stride3() {
39 ;CHECK-LABEL: load_i8_stride3
40 ;CHECK: Found an estimated cost of 1 for VF 1 For instruction: %1 = load
41 ;CHECK: Found an estimated cost of 1 for VF 2 For instruction: %1 = load
42 ;CHECK: Found an estimated cost of 1 for VF 4 For instruction: %1 = load
43 ;CHECK: Found an estimated cost of 4 for VF 8 For instruction: %1 = load
44 ;CHECK: Found an estimated cost of 13 for VF 16 For instruction: %1 = load
45 ;CHECK: Found an estimated cost of 16 for VF 32 For instruction: %1 = load
46 ;CHECK: Found an estimated cost of 25 for VF 64 For instruction: %1 = load
50 for.body: ; preds = %for.body, %entry
51 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
52 %0 = mul nsw i64 %indvars.iv, 3
53 %arrayidx = getelementptr inbounds [10240 x i8], ptr @A, i64 0, i64 %0
54 %1 = load i8, ptr %arrayidx, align 2
55 %arrayidx2 = getelementptr inbounds [10240 x i8], ptr @B, i64 0, i64 %indvars.iv
56 store i8 %1, ptr %arrayidx2, align 1
57 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
58 %exitcond = icmp eq i64 %indvars.iv.next, 1024
59 br i1 %exitcond, label %for.end, label %for.body
61 for.end: ; preds = %for.body
65 define void @load_i8_stride4() {
66 ;CHECK-LABEL: load_i8_stride4
67 ;CHECK: Found an estimated cost of 1 for VF 1 For instruction: %1 = load
68 ;CHECK: Found an estimated cost of 1 for VF 2 For instruction: %1 = load
69 ;CHECK: Found an estimated cost of 1 for VF 4 For instruction: %1 = load
70 ;CHECK: Found an estimated cost of 4 for VF 8 For instruction: %1 = load
71 ;CHECK: Found an estimated cost of 8 for VF 16 For instruction: %1 = load
72 ;CHECK: Found an estimated cost of 20 for VF 32 For instruction: %1 = load
73 ;CHECK: Found an estimated cost of 59 for VF 64 For instruction: %1 = load
77 for.body: ; preds = %for.body, %entry
78 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
79 %0 = shl nsw i64 %indvars.iv, 2
80 %arrayidx = getelementptr inbounds [10240 x i8], ptr @A, i64 0, i64 %0
81 %1 = load i8, ptr %arrayidx, align 2
82 %arrayidx2 = getelementptr inbounds [10240 x i8], ptr @B, i64 0, i64 %indvars.iv
83 store i8 %1, ptr %arrayidx2, align 1
84 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
85 %exitcond = icmp eq i64 %indvars.iv.next, 1024
86 br i1 %exitcond, label %for.end, label %for.body
88 for.end: ; preds = %for.body
92 define void @load_i8_stride5() {
93 ;CHECK-LABEL: load_i8_stride5
94 ;CHECK: Found an estimated cost of 1 for VF 1 For instruction: %1 = load
95 ;CHECK: Found an estimated cost of 1 for VF 2 For instruction: %1 = load
96 ;CHECK: Found an estimated cost of 4 for VF 4 For instruction: %1 = load
97 ;CHECK: Found an estimated cost of 8 for VF 8 For instruction: %1 = load
98 ;CHECK: Found an estimated cost of 20 for VF 16 For instruction: %1 = load
99 ;CHECK: Found an estimated cost of 39 for VF 32 For instruction: %1 = load
100 ;CHECK: Found an estimated cost of 78 for VF 64 For instruction: %1 = load
104 for.body: ; preds = %for.body, %entry
105 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
106 %0 = mul nsw i64 %indvars.iv, 5
107 %arrayidx = getelementptr inbounds [10240 x i8], ptr @A, i64 0, i64 %0
108 %1 = load i8, ptr %arrayidx, align 2
109 %arrayidx2 = getelementptr inbounds [10240 x i8], ptr @B, i64 0, i64 %indvars.iv
110 store i8 %1, ptr %arrayidx2, align 1
111 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
112 %exitcond = icmp eq i64 %indvars.iv.next, 1024
113 br i1 %exitcond, label %for.end, label %for.body
115 for.end: ; preds = %for.body