1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -mtriple=x86_64-pc-linux-gnu -mcpu=generic -passes=slp-vectorizer -pass-remarks-output=%t < %s | FileCheck %s
3 ; RUN: FileCheck --input-file=%t --check-prefix=YAML %s
5 define i32 @foo(ptr nocapture readonly %diff) #0 {
8 ; CHECK-NEXT: [[M2:%.*]] = alloca [8 x [8 x i32]], align 16
9 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
11 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
12 ; CHECK-NEXT: [[A_088:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[ADD24:%.*]], [[FOR_BODY]] ]
13 ; CHECK-NEXT: [[TMP0:%.*]] = shl i64 [[INDVARS_IV]], 3
14 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[DIFF:%.*]], i64 [[TMP0]]
15 ; CHECK-NEXT: [[TMP1:%.*]] = or disjoint i64 [[TMP0]], 4
16 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, ptr [[DIFF]], i64 [[TMP1]]
17 ; CHECK-NEXT: [[ARRAYIDX6:%.*]] = getelementptr inbounds [8 x [8 x i32]], ptr [[M2]], i64 0, i64 [[INDVARS_IV]], i64 0
18 ; CHECK-NEXT: [[TMP2:%.*]] = load <2 x i32>, ptr [[ARRAYIDX]], align 4
19 ; CHECK-NEXT: [[TMP3:%.*]] = load <2 x i32>, ptr [[ARRAYIDX2]], align 4
20 ; CHECK-NEXT: [[TMP4:%.*]] = add nsw <2 x i32> [[TMP3]], [[TMP2]]
21 ; CHECK-NEXT: [[TMP5:%.*]] = extractelement <2 x i32> [[TMP4]], i32 0
22 ; CHECK-NEXT: [[ADD10:%.*]] = add nsw i32 [[TMP5]], [[A_088]]
23 ; CHECK-NEXT: store <2 x i32> [[TMP4]], ptr [[ARRAYIDX6]], align 16
24 ; CHECK-NEXT: [[TMP6:%.*]] = extractelement <2 x i32> [[TMP4]], i32 1
25 ; CHECK-NEXT: [[ADD24]] = add nsw i32 [[ADD10]], [[TMP6]]
26 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
27 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 8
28 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
30 ; CHECK-NEXT: ret i32 [[ADD24]]
33 %m2 = alloca [8 x [8 x i32]], align 16
36 for.body: ; preds = %for.body, %entry
37 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
38 %a.088 = phi i32 [ 0, %entry ], [ %add24, %for.body ]
39 %0 = shl i64 %indvars.iv, 3
40 %arrayidx = getelementptr inbounds i32, ptr %diff, i64 %0
41 %1 = load i32, ptr %arrayidx, align 4
42 %2 = or disjoint i64 %0, 4
43 %arrayidx2 = getelementptr inbounds i32, ptr %diff, i64 %2
44 %3 = load i32, ptr %arrayidx2, align 4
45 %add3 = add nsw i32 %3, %1
46 %arrayidx6 = getelementptr inbounds [8 x [8 x i32]], ptr %m2, i64 0, i64 %indvars.iv, i64 0
47 store i32 %add3, ptr %arrayidx6, align 16
48 %add10 = add nsw i32 %add3, %a.088
49 %4 = or disjoint i64 %0, 1
50 %arrayidx13 = getelementptr inbounds i32, ptr %diff, i64 %4
51 %5 = load i32, ptr %arrayidx13, align 4
52 %6 = or disjoint i64 %0, 5
53 %arrayidx16 = getelementptr inbounds i32, ptr %diff, i64 %6
54 %7 = load i32, ptr %arrayidx16, align 4
55 %add17 = add nsw i32 %7, %5
56 %arrayidx20 = getelementptr inbounds [8 x [8 x i32]], ptr %m2, i64 0, i64 %indvars.iv, i64 1
57 store i32 %add17, ptr %arrayidx20, align 4
58 %add24 = add nsw i32 %add10, %add17
60 ; YAML: Pass: slp-vectorizer
61 ; YAML-NEXT: Name: StoresVectorized
62 ; YAML-NEXT: Function: foo
64 ; YAML-NEXT: - String: 'Stores SLP vectorized with cost '
65 ; YAML-NEXT: - Cost: '-1'
66 ; YAML-NEXT: - String: ' and with tree size '
67 ; YAML-NEXT: - TreeSize: '4'
69 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
70 %exitcond = icmp eq i64 %indvars.iv.next, 8
71 br i1 %exitcond, label %for.end, label %for.body
73 for.end: ; preds = %for.body