1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=slp-vectorizer,dce -S -mtriple=i386-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s
4 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32-S128"
5 target triple = "i386-apple-macosx10.9.0"
7 ;int foo(int *A, int n, int k) {
8 ; for (int i=0; i < 10000; i+=4) {
16 define i32 @foo(ptr nocapture %A, i32 %n, i32 %k) {
19 ; CHECK-NEXT: [[TMP0:%.*]] = insertelement <4 x i32> poison, i32 [[N:%.*]], i32 0
20 ; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x i32> [[TMP0]], i32 [[K:%.*]], i32 1
21 ; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
22 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
24 ; CHECK-NEXT: [[I_024:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[ADD10:%.*]], [[FOR_BODY]] ]
25 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i32 [[I_024]]
26 ; CHECK-NEXT: [[TMP3:%.*]] = load <4 x i32>, ptr [[ARRAYIDX]], align 4
27 ; CHECK-NEXT: [[TMP4:%.*]] = add nsw <4 x i32> [[TMP3]], [[TMP2]]
28 ; CHECK-NEXT: store <4 x i32> [[TMP4]], ptr [[ARRAYIDX]], align 4
29 ; CHECK-NEXT: [[ADD10]] = add nsw i32 [[I_024]], 4
30 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[ADD10]], 10000
31 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END:%.*]]
33 ; CHECK-NEXT: ret i32 undef
38 for.body: ; preds = %entry, %for.body
39 %i.024 = phi i32 [ 0, %entry ], [ %add10, %for.body ]
40 %arrayidx = getelementptr inbounds i32, ptr %A, i32 %i.024
41 %0 = load i32, ptr %arrayidx, align 4
42 %add = add nsw i32 %0, %n
43 store i32 %add, ptr %arrayidx, align 4
44 %add121 = or disjoint i32 %i.024, 1
45 %arrayidx2 = getelementptr inbounds i32, ptr %A, i32 %add121
46 %1 = load i32, ptr %arrayidx2, align 4
47 %add3 = add nsw i32 %1, %k
48 store i32 %add3, ptr %arrayidx2, align 4
49 %add422 = or disjoint i32 %i.024, 2
50 %arrayidx5 = getelementptr inbounds i32, ptr %A, i32 %add422
51 %2 = load i32, ptr %arrayidx5, align 4
52 %add6 = add nsw i32 %2, %n
53 store i32 %add6, ptr %arrayidx5, align 4
54 %add723 = or disjoint i32 %i.024, 3
55 %arrayidx8 = getelementptr inbounds i32, ptr %A, i32 %add723
56 %3 = load i32, ptr %arrayidx8, align 4
57 %add9 = add nsw i32 %3, %k
58 store i32 %add9, ptr %arrayidx8, align 4
59 %add10 = add nsw i32 %i.024, 4
60 %cmp = icmp slt i32 %add10, 10000
61 br i1 %cmp, label %for.body, label %for.end
63 for.end: ; preds = %for.body