1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -mtriple=x86_64-pc-linux-gnu -mcpu=generic -slp-vectorizer -pass-remarks-output=%t < %s | FileCheck %s
3 ; RUN: FileCheck --input-file=%t --check-prefix=YAML %s
5 define i32 @foo(i32* nocapture readonly %diff) #0 {
8 ; CHECK-NEXT: [[M2:%.*]] = alloca [8 x [8 x i32]], align 16
9 ; CHECK-NEXT: [[TMP0:%.*]] = bitcast [8 x [8 x i32]]* [[M2]] to i8*
10 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
12 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
13 ; CHECK-NEXT: [[A_088:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[ADD24:%.*]], [[FOR_BODY]] ]
14 ; CHECK-NEXT: [[TMP1:%.*]] = shl i64 [[INDVARS_IV]], 3
15 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[DIFF:%.*]], i64 [[TMP1]]
16 ; CHECK-NEXT: [[TMP2:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
17 ; CHECK-NEXT: [[TMP3:%.*]] = or i64 [[TMP1]], 4
18 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, i32* [[DIFF]], i64 [[TMP3]]
19 ; CHECK-NEXT: [[TMP4:%.*]] = load i32, i32* [[ARRAYIDX2]], align 4
20 ; CHECK-NEXT: [[ADD3:%.*]] = add nsw i32 [[TMP4]], [[TMP2]]
21 ; CHECK-NEXT: [[ARRAYIDX6:%.*]] = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* [[M2]], i64 0, i64 [[INDVARS_IV]], i64 0
22 ; CHECK-NEXT: store i32 [[ADD3]], i32* [[ARRAYIDX6]], align 16
23 ; CHECK-NEXT: [[ADD10:%.*]] = add nsw i32 [[ADD3]], [[A_088]]
24 ; CHECK-NEXT: [[TMP5:%.*]] = or i64 [[TMP1]], 1
25 ; CHECK-NEXT: [[ARRAYIDX13:%.*]] = getelementptr inbounds i32, i32* [[DIFF]], i64 [[TMP5]]
26 ; CHECK-NEXT: [[TMP6:%.*]] = load i32, i32* [[ARRAYIDX13]], align 4
27 ; CHECK-NEXT: [[TMP7:%.*]] = or i64 [[TMP1]], 5
28 ; CHECK-NEXT: [[ARRAYIDX16:%.*]] = getelementptr inbounds i32, i32* [[DIFF]], i64 [[TMP7]]
29 ; CHECK-NEXT: [[TMP8:%.*]] = load i32, i32* [[ARRAYIDX16]], align 4
30 ; CHECK-NEXT: [[ADD17:%.*]] = add nsw i32 [[TMP8]], [[TMP6]]
31 ; CHECK-NEXT: [[ARRAYIDX20:%.*]] = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* [[M2]], i64 0, i64 [[INDVARS_IV]], i64 1
32 ; CHECK-NEXT: store i32 [[ADD17]], i32* [[ARRAYIDX20]], align 4
33 ; CHECK-NEXT: [[ADD24]] = add nsw i32 [[ADD10]], [[ADD17]]
34 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
35 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 8
36 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
38 ; CHECK-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* [[M2]], i64 0, i64 0
39 ; CHECK-NEXT: ret i32 [[ADD24]]
42 %m2 = alloca [8 x [8 x i32]], align 16
43 %0 = bitcast [8 x [8 x i32]]* %m2 to i8*
46 for.body: ; preds = %for.body, %entry
47 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
48 %a.088 = phi i32 [ 0, %entry ], [ %add24, %for.body ]
49 %1 = shl i64 %indvars.iv, 3
50 %arrayidx = getelementptr inbounds i32, i32* %diff, i64 %1
51 %2 = load i32, i32* %arrayidx, align 4
53 %arrayidx2 = getelementptr inbounds i32, i32* %diff, i64 %3
54 %4 = load i32, i32* %arrayidx2, align 4
55 %add3 = add nsw i32 %4, %2
56 %arrayidx6 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %m2, i64 0, i64 %indvars.iv, i64 0
57 store i32 %add3, i32* %arrayidx6, align 16
58 %add10 = add nsw i32 %add3, %a.088
60 %arrayidx13 = getelementptr inbounds i32, i32* %diff, i64 %5
61 %6 = load i32, i32* %arrayidx13, align 4
63 %arrayidx16 = getelementptr inbounds i32, i32* %diff, i64 %7
64 %8 = load i32, i32* %arrayidx16, align 4
65 %add17 = add nsw i32 %8, %6
66 %arrayidx20 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %m2, i64 0, i64 %indvars.iv, i64 1
67 store i32 %add17, i32* %arrayidx20, align 4
68 %add24 = add nsw i32 %add10, %add17
70 ; YAML: Pass: slp-vectorizer
71 ; YAML-NEXT: Name: NotPossible
72 ; YAML-NEXT: Function: foo
74 ; YAML-NEXT: - String: 'Cannot SLP vectorize list: vectorization was impossible'
75 ; YAML-NEXT: - String: ' with available vectorization factors'
77 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
78 %exitcond = icmp eq i64 %indvars.iv.next, 8
79 br i1 %exitcond, label %for.end, label %for.body
81 for.end: ; preds = %for.body
82 %arraydecay = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %m2, i64 0, i64 0