1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=slp-vectorizer -S -mcpu=corei7-avx | FileCheck %s
4 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
5 target triple = "x86_64-apple-macosx10.8.0"
7 define i32 @foo(ptr nocapture %A, i32 %n) {
10 ; CHECK-NEXT: [[CMP62:%.*]] = icmp sgt i32 [[N:%.*]], 0
11 ; CHECK-NEXT: br i1 [[CMP62]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]]
13 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
14 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[INDVARS_IV]]
15 ; CHECK-NEXT: [[TMP0:%.*]] = load <8 x i32>, ptr [[ARRAYIDX]], align 4
16 ; CHECK-NEXT: [[TMP1:%.*]] = insertelement <8 x i32> poison, i32 [[N]], i32 0
17 ; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <8 x i32> [[TMP1]], <8 x i32> poison, <8 x i32> zeroinitializer
18 ; CHECK-NEXT: [[TMP3:%.*]] = add nsw <8 x i32> [[TMP0]], [[TMP2]]
19 ; CHECK-NEXT: store <8 x i32> [[TMP3]], ptr [[ARRAYIDX]], align 4
20 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add i64 [[INDVARS_IV]], 8
21 ; CHECK-NEXT: [[TMP4:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
22 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[TMP4]], [[N]]
23 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END]]
25 ; CHECK-NEXT: ret i32 undef
28 %cmp62 = icmp sgt i32 %n, 0
29 br i1 %cmp62, label %for.body, label %for.end
32 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
33 %arrayidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
34 %0 = load i32, ptr %arrayidx, align 4
35 %add1 = add nsw i32 %0, %n
36 store i32 %add1, ptr %arrayidx, align 4
37 %1 = or disjoint i64 %indvars.iv, 1
38 %arrayidx4 = getelementptr inbounds i32, ptr %A, i64 %1
39 %2 = load i32, ptr %arrayidx4, align 4
40 %add5 = add nsw i32 %2, %n
41 store i32 %add5, ptr %arrayidx4, align 4
42 %3 = or disjoint i64 %indvars.iv, 2
43 %arrayidx8 = getelementptr inbounds i32, ptr %A, i64 %3
44 %4 = load i32, ptr %arrayidx8, align 4
45 %add9 = add nsw i32 %4, %n
46 store i32 %add9, ptr %arrayidx8, align 4
47 %5 = or disjoint i64 %indvars.iv, 3
48 %arrayidx12 = getelementptr inbounds i32, ptr %A, i64 %5
49 %6 = load i32, ptr %arrayidx12, align 4
50 %add13 = add nsw i32 %6, %n
51 store i32 %add13, ptr %arrayidx12, align 4
52 %7 = or disjoint i64 %indvars.iv, 4
53 %arrayidx16 = getelementptr inbounds i32, ptr %A, i64 %7
54 %8 = load i32, ptr %arrayidx16, align 4
55 %add17 = add nsw i32 %8, %n
56 store i32 %add17, ptr %arrayidx16, align 4
57 %9 = or disjoint i64 %indvars.iv, 5
58 %arrayidx20 = getelementptr inbounds i32, ptr %A, i64 %9
59 %10 = load i32, ptr %arrayidx20, align 4
60 %add21 = add nsw i32 %10, %n
61 store i32 %add21, ptr %arrayidx20, align 4
62 %11 = or disjoint i64 %indvars.iv, 6
63 %arrayidx24 = getelementptr inbounds i32, ptr %A, i64 %11
64 %12 = load i32, ptr %arrayidx24, align 4
65 %add25 = add nsw i32 %12, %n
66 store i32 %add25, ptr %arrayidx24, align 4
67 %13 = or disjoint i64 %indvars.iv, 7
68 %arrayidx28 = getelementptr inbounds i32, ptr %A, i64 %13
69 %14 = load i32, ptr %arrayidx28, align 4
70 %add29 = add nsw i32 %14, %n
71 store i32 %add29, ptr %arrayidx28, align 4
72 %indvars.iv.next = add i64 %indvars.iv, 8
73 %15 = trunc i64 %indvars.iv.next to i32
74 %cmp = icmp slt i32 %15, %n
75 br i1 %cmp, label %for.body, label %for.end