1 ; RUN: opt -loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,SSE2
2 ; RUN: opt -loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,AVX1
3 ; RUN: opt -loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,AVX2
4 ; RUN: opt -loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512bw,+avx512vl --debug-only=loop-vectorize < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,AVX512
7 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
8 target triple = "x86_64-unknown-linux-gnu"
10 @A = global [1024 x i64] zeroinitializer, align 128
11 @B = global [1024 x i8] zeroinitializer, align 128
13 ; CHECK: LV: Checking a loop in "test"
15 ; SSE2: LV: Found an estimated cost of 1 for VF 1 For instruction: %v0 = load i64, i64* %in0, align 8
16 ; SSE2: LV: Found an estimated cost of 42 for VF 2 For instruction: %v0 = load i64, i64* %in0, align 8
17 ; SSE2: LV: Found an estimated cost of 84 for VF 4 For instruction: %v0 = load i64, i64* %in0, align 8
19 ; AVX1: LV: Found an estimated cost of 1 for VF 1 For instruction: %v0 = load i64, i64* %in0, align 8
20 ; AVX1: LV: Found an estimated cost of 33 for VF 2 For instruction: %v0 = load i64, i64* %in0, align 8
21 ; AVX1: LV: Found an estimated cost of 78 for VF 4 For instruction: %v0 = load i64, i64* %in0, align 8
22 ; AVX1: LV: Found an estimated cost of 156 for VF 8 For instruction: %v0 = load i64, i64* %in0, align 8
24 ; AVX2: LV: Found an estimated cost of 1 for VF 1 For instruction: %v0 = load i64, i64* %in0, align 8
25 ; AVX2: LV: Found an estimated cost of 9 for VF 2 For instruction: %v0 = load i64, i64* %in0, align 8
26 ; AVX2: LV: Found an estimated cost of 24 for VF 4 For instruction: %v0 = load i64, i64* %in0, align 8
27 ; AVX2: LV: Found an estimated cost of 48 for VF 8 For instruction: %v0 = load i64, i64* %in0, align 8
29 ; AVX512: LV: Found an estimated cost of 1 for VF 1 For instruction: %v0 = load i64, i64* %in0, align 8
30 ; AVX512: LV: Found an estimated cost of 11 for VF 2 For instruction: %v0 = load i64, i64* %in0, align 8
31 ; AVX512: LV: Found an estimated cost of 21 for VF 4 For instruction: %v0 = load i64, i64* %in0, align 8
32 ; AVX512: LV: Found an estimated cost of 51 for VF 8 For instruction: %v0 = load i64, i64* %in0, align 8
33 ; AVX512: LV: Found an estimated cost of 120 for VF 16 For instruction: %v0 = load i64, i64* %in0, align 8
34 ; AVX512: LV: Found an estimated cost of 240 for VF 32 For instruction: %v0 = load i64, i64* %in0, align 8
36 ; CHECK-NOT: LV: Found an estimated cost of {{[0-9]+}} for VF {{[0-9]+}} For instruction: %v0 = load i64, i64* %in0, align 8
43 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
45 %iv.0 = add nuw nsw i64 %iv, 0
46 %iv.1 = add nuw nsw i64 %iv, 1
47 %iv.2 = add nuw nsw i64 %iv, 2
48 %iv.3 = add nuw nsw i64 %iv, 3
49 %iv.4 = add nuw nsw i64 %iv, 4
50 %iv.5 = add nuw nsw i64 %iv, 5
52 %in0 = getelementptr inbounds [1024 x i64], [1024 x i64]* @A, i64 0, i64 %iv.0
53 %in1 = getelementptr inbounds [1024 x i64], [1024 x i64]* @A, i64 0, i64 %iv.1
54 %in2 = getelementptr inbounds [1024 x i64], [1024 x i64]* @A, i64 0, i64 %iv.2
55 %in3 = getelementptr inbounds [1024 x i64], [1024 x i64]* @A, i64 0, i64 %iv.3
56 %in4 = getelementptr inbounds [1024 x i64], [1024 x i64]* @A, i64 0, i64 %iv.4
57 %in5 = getelementptr inbounds [1024 x i64], [1024 x i64]* @A, i64 0, i64 %iv.5
59 %v0 = load i64, i64* %in0
60 %v1 = load i64, i64* %in1
61 %v2 = load i64, i64* %in2
62 %v3 = load i64, i64* %in3
63 %v4 = load i64, i64* %in4
64 %v5 = load i64, i64* %in5
66 %reduce.add.0 = add i64 %v0, %v1
67 %reduce.add.1 = add i64 %reduce.add.0, %v2
68 %reduce.add.2 = add i64 %reduce.add.1, %v3
69 %reduce.add.3 = add i64 %reduce.add.2, %v4
70 %reduce.add.4 = add i64 %reduce.add.3, %v5
72 %reduce.add.4.narrow = trunc i64 %reduce.add.4 to i8
74 %out = getelementptr inbounds [1024 x i8], [1024 x i8]* @B, i64 0, i64 %iv.0
75 store i8 %reduce.add.4.narrow, i8* %out
77 %iv.next = add nuw nsw i64 %iv.0, 6
78 %cmp = icmp ult i64 %iv.next, 1024
79 br i1 %cmp, label %for.body, label %for.cond.cleanup