1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=slp-vectorizer -S -mtriple=i386-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s
4 define i32 @foo(ptr nocapture readonly %diff) #0 {
7 ; CHECK-NEXT: [[M2:%.*]] = alloca [8 x [8 x i32]], align 16
8 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
10 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
11 ; CHECK-NEXT: [[A_088:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[OP_RDX:%.*]], [[FOR_BODY]] ]
12 ; CHECK-NEXT: [[TMP0:%.*]] = shl i64 [[INDVARS_IV]], 3
13 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[DIFF:%.*]], i64 [[TMP0]]
14 ; CHECK-NEXT: [[TMP1:%.*]] = or disjoint i64 [[TMP0]], 4
15 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, ptr [[DIFF]], i64 [[TMP1]]
16 ; CHECK-NEXT: [[ARRAYIDX6:%.*]] = getelementptr inbounds [8 x [8 x i32]], ptr [[M2]], i64 0, i64 [[INDVARS_IV]], i64 0
17 ; CHECK-NEXT: [[TMP2:%.*]] = load <4 x i32>, ptr [[ARRAYIDX]], align 4
18 ; CHECK-NEXT: [[TMP3:%.*]] = load <4 x i32>, ptr [[ARRAYIDX2]], align 4
19 ; CHECK-NEXT: [[TMP4:%.*]] = add nsw <4 x i32> [[TMP3]], [[TMP2]]
20 ; CHECK-NEXT: store <4 x i32> [[TMP4]], ptr [[ARRAYIDX6]], align 16
21 ; CHECK-NEXT: [[TMP5:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[TMP4]])
22 ; CHECK-NEXT: [[OP_RDX]] = add i32 [[TMP5]], [[A_088]]
23 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
24 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 8
25 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
27 ; CHECK-NEXT: call void @ff(ptr [[M2]])
28 ; CHECK-NEXT: ret i32 [[OP_RDX]]
31 %m2 = alloca [8 x [8 x i32]], align 16
34 for.body: ; preds = %for.body, %entry
35 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
36 %a.088 = phi i32 [ 0, %entry ], [ %add52, %for.body ]
37 %0 = shl i64 %indvars.iv, 3
38 %arrayidx = getelementptr inbounds i32, ptr %diff, i64 %0
39 %1 = load i32, ptr %arrayidx, align 4
40 %2 = or disjoint i64 %0, 4
41 %arrayidx2 = getelementptr inbounds i32, ptr %diff, i64 %2
42 %3 = load i32, ptr %arrayidx2, align 4
43 %add3 = add nsw i32 %3, %1
44 %arrayidx6 = getelementptr inbounds [8 x [8 x i32]], ptr %m2, i64 0, i64 %indvars.iv, i64 0
45 store i32 %add3, ptr %arrayidx6, align 16
46 %add10 = add nsw i32 %add3, %a.088
47 %4 = or disjoint i64 %0, 1
48 %arrayidx13 = getelementptr inbounds i32, ptr %diff, i64 %4
49 %5 = load i32, ptr %arrayidx13, align 4
50 %6 = or disjoint i64 %0, 5
51 %arrayidx16 = getelementptr inbounds i32, ptr %diff, i64 %6
52 %7 = load i32, ptr %arrayidx16, align 4
53 %add17 = add nsw i32 %7, %5
54 %arrayidx20 = getelementptr inbounds [8 x [8 x i32]], ptr %m2, i64 0, i64 %indvars.iv, i64 1
55 store i32 %add17, ptr %arrayidx20, align 4
56 %add24 = add nsw i32 %add10, %add17
57 %8 = or disjoint i64 %0, 2
58 %arrayidx27 = getelementptr inbounds i32, ptr %diff, i64 %8
59 %9 = load i32, ptr %arrayidx27, align 4
60 %10 = or disjoint i64 %0, 6
61 %arrayidx30 = getelementptr inbounds i32, ptr %diff, i64 %10
62 %11 = load i32, ptr %arrayidx30, align 4
63 %add31 = add nsw i32 %11, %9
64 %arrayidx34 = getelementptr inbounds [8 x [8 x i32]], ptr %m2, i64 0, i64 %indvars.iv, i64 2
65 store i32 %add31, ptr %arrayidx34, align 8
66 %add38 = add nsw i32 %add24, %add31
67 %12 = or disjoint i64 %0, 3
68 %arrayidx41 = getelementptr inbounds i32, ptr %diff, i64 %12
69 %13 = load i32, ptr %arrayidx41, align 4
70 %14 = or disjoint i64 %0, 7
71 %arrayidx44 = getelementptr inbounds i32, ptr %diff, i64 %14
72 %15 = load i32, ptr %arrayidx44, align 4
73 %add45 = add nsw i32 %15, %13
74 %arrayidx48 = getelementptr inbounds [8 x [8 x i32]], ptr %m2, i64 0, i64 %indvars.iv, i64 3
75 store i32 %add45, ptr %arrayidx48, align 4
76 %add52 = add nsw i32 %add38, %add45
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 call void @ff(ptr %m2) #1
86 declare void @ff(ptr) #2