1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -basicaa -slp-vectorizer -S -mtriple=i386-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s
4 define i32 @foo(i32* nocapture readonly %diff) #0 {
6 ; CHECK: load <4 x i32>
7 ; CHECK: load <4 x i32>
8 ; CHECK: [[S1:%.+]] = add nsw <4 x i32>
9 ; CHECK: store <4 x i32> [[S1]],
10 ; CHECK: [[RDX_SHUF:%.*]] = shufflevector <4 x i32> [[S1]], <4 x i32> undef, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef>
11 ; CHECK-NEXT: [[BIN_RDX:%.*]] = add nsw <4 x i32> [[S1]], [[RDX_SHUF]]
12 ; CHECK-NEXT: [[RDX_SHUF1:%.*]] = shufflevector <4 x i32> [[BIN_RDX]], <4 x i32> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
13 ; CHECK-NEXT: [[BIN_RDX2:%.*]] = add nsw <4 x i32> [[BIN_RDX]], [[RDX_SHUF1]]
14 ; CHECK-NEXT: [[TMP15:%.*]] = extractelement <4 x i32> [[BIN_RDX2]], i32 0
15 ; CHECK: [[ADD52:%.*]] = add nsw i32 [[TMP15]],
16 ; CHECK: ret i32 [[ADD52]]
19 %m2 = alloca [8 x [8 x i32]], align 16
20 %0 = bitcast [8 x [8 x i32]]* %m2 to i8*
23 for.body: ; preds = %for.body, %entry
24 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
25 %a.088 = phi i32 [ 0, %entry ], [ %add52, %for.body ]
26 %1 = shl i64 %indvars.iv, 3
27 %arrayidx = getelementptr inbounds i32, i32* %diff, i64 %1
28 %2 = load i32, i32* %arrayidx, align 4
30 %arrayidx2 = getelementptr inbounds i32, i32* %diff, i64 %3
31 %4 = load i32, i32* %arrayidx2, align 4
32 %add3 = add nsw i32 %4, %2
33 %arrayidx6 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %m2, i64 0, i64 %indvars.iv, i64 0
34 store i32 %add3, i32* %arrayidx6, align 16
35 %add10 = add nsw i32 %add3, %a.088
37 %arrayidx13 = getelementptr inbounds i32, i32* %diff, i64 %5
38 %6 = load i32, i32* %arrayidx13, align 4
40 %arrayidx16 = getelementptr inbounds i32, i32* %diff, i64 %7
41 %8 = load i32, i32* %arrayidx16, align 4
42 %add17 = add nsw i32 %8, %6
43 %arrayidx20 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %m2, i64 0, i64 %indvars.iv, i64 1
44 store i32 %add17, i32* %arrayidx20, align 4
45 %add24 = add nsw i32 %add10, %add17
47 %arrayidx27 = getelementptr inbounds i32, i32* %diff, i64 %9
48 %10 = load i32, i32* %arrayidx27, align 4
50 %arrayidx30 = getelementptr inbounds i32, i32* %diff, i64 %11
51 %12 = load i32, i32* %arrayidx30, align 4
52 %add31 = add nsw i32 %12, %10
53 %arrayidx34 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %m2, i64 0, i64 %indvars.iv, i64 2
54 store i32 %add31, i32* %arrayidx34, align 8
55 %add38 = add nsw i32 %add24, %add31
57 %arrayidx41 = getelementptr inbounds i32, i32* %diff, i64 %13
58 %14 = load i32, i32* %arrayidx41, align 4
60 %arrayidx44 = getelementptr inbounds i32, i32* %diff, i64 %15
61 %16 = load i32, i32* %arrayidx44, align 4
62 %add45 = add nsw i32 %16, %14
63 %arrayidx48 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %m2, i64 0, i64 %indvars.iv, i64 3
64 store i32 %add45, i32* %arrayidx48, align 4
65 %add52 = add nsw i32 %add38, %add45
66 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
67 %exitcond = icmp eq i64 %indvars.iv.next, 8
68 br i1 %exitcond, label %for.end, label %for.body
70 for.end: ; preds = %for.body
71 %arraydecay = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %m2, i64 0, i64 0
72 call void @ff([8 x i32]* %arraydecay) #1
76 declare void @ff([8 x i32]*) #2