1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -basicaa -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(i32* 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, i32* [[A:%.*]], i64 [[INDVARS_IV]]
15 ; CHECK-NEXT: [[TMP0:%.*]] = or i64 [[INDVARS_IV]], 1
16 ; CHECK-NEXT: [[ARRAYIDX4:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 [[TMP0]]
17 ; CHECK-NEXT: [[TMP1:%.*]] = or i64 [[INDVARS_IV]], 2
18 ; CHECK-NEXT: [[ARRAYIDX8:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 [[TMP1]]
19 ; CHECK-NEXT: [[TMP2:%.*]] = or i64 [[INDVARS_IV]], 3
20 ; CHECK-NEXT: [[ARRAYIDX12:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 [[TMP2]]
21 ; CHECK-NEXT: [[TMP3:%.*]] = or i64 [[INDVARS_IV]], 4
22 ; CHECK-NEXT: [[ARRAYIDX16:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 [[TMP3]]
23 ; CHECK-NEXT: [[TMP4:%.*]] = or i64 [[INDVARS_IV]], 5
24 ; CHECK-NEXT: [[ARRAYIDX20:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 [[TMP4]]
25 ; CHECK-NEXT: [[TMP5:%.*]] = or i64 [[INDVARS_IV]], 6
26 ; CHECK-NEXT: [[ARRAYIDX24:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 [[TMP5]]
27 ; CHECK-NEXT: [[TMP6:%.*]] = or i64 [[INDVARS_IV]], 7
28 ; CHECK-NEXT: [[ARRAYIDX28:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 [[TMP6]]
29 ; CHECK-NEXT: [[TMP7:%.*]] = bitcast i32* [[ARRAYIDX]] to <8 x i32>*
30 ; CHECK-NEXT: [[TMP8:%.*]] = load <8 x i32>, <8 x i32>* [[TMP7]], align 4
31 ; CHECK-NEXT: [[TMP9:%.*]] = insertelement <8 x i32> undef, i32 [[N]], i32 0
32 ; CHECK-NEXT: [[TMP10:%.*]] = insertelement <8 x i32> [[TMP9]], i32 [[N]], i32 1
33 ; CHECK-NEXT: [[TMP11:%.*]] = insertelement <8 x i32> [[TMP10]], i32 [[N]], i32 2
34 ; CHECK-NEXT: [[TMP12:%.*]] = insertelement <8 x i32> [[TMP11]], i32 [[N]], i32 3
35 ; CHECK-NEXT: [[TMP13:%.*]] = insertelement <8 x i32> [[TMP12]], i32 [[N]], i32 4
36 ; CHECK-NEXT: [[TMP14:%.*]] = insertelement <8 x i32> [[TMP13]], i32 [[N]], i32 5
37 ; CHECK-NEXT: [[TMP15:%.*]] = insertelement <8 x i32> [[TMP14]], i32 [[N]], i32 6
38 ; CHECK-NEXT: [[TMP16:%.*]] = insertelement <8 x i32> [[TMP15]], i32 [[N]], i32 7
39 ; CHECK-NEXT: [[TMP17:%.*]] = add nsw <8 x i32> [[TMP8]], [[TMP16]]
40 ; CHECK-NEXT: [[TMP18:%.*]] = bitcast i32* [[ARRAYIDX]] to <8 x i32>*
41 ; CHECK-NEXT: store <8 x i32> [[TMP17]], <8 x i32>* [[TMP18]], align 4
42 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add i64 [[INDVARS_IV]], 8
43 ; CHECK-NEXT: [[TMP19:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
44 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[TMP19]], [[N]]
45 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END]]
47 ; CHECK-NEXT: ret i32 undef
50 %cmp62 = icmp sgt i32 %n, 0
51 br i1 %cmp62, label %for.body, label %for.end
54 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
55 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
56 %0 = load i32, i32* %arrayidx, align 4
57 %add1 = add nsw i32 %0, %n
58 store i32 %add1, i32* %arrayidx, align 4
59 %1 = or i64 %indvars.iv, 1
60 %arrayidx4 = getelementptr inbounds i32, i32* %A, i64 %1
61 %2 = load i32, i32* %arrayidx4, align 4
62 %add5 = add nsw i32 %2, %n
63 store i32 %add5, i32* %arrayidx4, align 4
64 %3 = or i64 %indvars.iv, 2
65 %arrayidx8 = getelementptr inbounds i32, i32* %A, i64 %3
66 %4 = load i32, i32* %arrayidx8, align 4
67 %add9 = add nsw i32 %4, %n
68 store i32 %add9, i32* %arrayidx8, align 4
69 %5 = or i64 %indvars.iv, 3
70 %arrayidx12 = getelementptr inbounds i32, i32* %A, i64 %5
71 %6 = load i32, i32* %arrayidx12, align 4
72 %add13 = add nsw i32 %6, %n
73 store i32 %add13, i32* %arrayidx12, align 4
74 %7 = or i64 %indvars.iv, 4
75 %arrayidx16 = getelementptr inbounds i32, i32* %A, i64 %7
76 %8 = load i32, i32* %arrayidx16, align 4
77 %add17 = add nsw i32 %8, %n
78 store i32 %add17, i32* %arrayidx16, align 4
79 %9 = or i64 %indvars.iv, 5
80 %arrayidx20 = getelementptr inbounds i32, i32* %A, i64 %9
81 %10 = load i32, i32* %arrayidx20, align 4
82 %add21 = add nsw i32 %10, %n
83 store i32 %add21, i32* %arrayidx20, align 4
84 %11 = or i64 %indvars.iv, 6
85 %arrayidx24 = getelementptr inbounds i32, i32* %A, i64 %11
86 %12 = load i32, i32* %arrayidx24, align 4
87 %add25 = add nsw i32 %12, %n
88 store i32 %add25, i32* %arrayidx24, align 4
89 %13 = or i64 %indvars.iv, 7
90 %arrayidx28 = getelementptr inbounds i32, i32* %A, i64 %13
91 %14 = load i32, i32* %arrayidx28, align 4
92 %add29 = add nsw i32 %14, %n
93 store i32 %add29, i32* %arrayidx28, align 4
94 %indvars.iv.next = add i64 %indvars.iv, 8
95 %15 = trunc i64 %indvars.iv.next to i32
96 %cmp = icmp slt i32 %15, %n
97 br i1 %cmp, label %for.body, label %for.end