1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -basicaa -slp-vectorizer -dce -S -mtriple=x86_64-apple-macosx10.8.0 -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.9.0"
8 ; int r = A[0], g = A[1], b = A[2], a = A[3];
9 ; for (int i=0; i < A[13]; i++) {
10 ; r*=18; g*=19; b*=12; a *=9;
12 ; A[0] = r; A[1] = g; A[2] = b; A[3] = a;
15 define i32 @foo(i32* nocapture %A) #0 {
18 ; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32* [[A:%.*]] to <4 x i32>*
19 ; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, <4 x i32>* [[TMP0]], align 4
20 ; CHECK-NEXT: [[ARRAYIDX4:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 13
21 ; CHECK-NEXT: [[TMP2:%.*]] = load i32, i32* [[ARRAYIDX4]], align 4
22 ; CHECK-NEXT: [[CMP24:%.*]] = icmp sgt i32 [[TMP2]], 0
23 ; CHECK-NEXT: br i1 [[CMP24]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]]
25 ; CHECK-NEXT: [[I_029:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
26 ; CHECK-NEXT: [[TMP3:%.*]] = phi <4 x i32> [ [[TMP4:%.*]], [[FOR_BODY]] ], [ [[TMP1]], [[ENTRY]] ]
27 ; CHECK-NEXT: [[TMP4]] = mul nsw <4 x i32> [[TMP3]], <i32 18, i32 19, i32 12, i32 9>
28 ; CHECK-NEXT: [[INC]] = add nsw i32 [[I_029]], 1
29 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[TMP2]]
30 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END]]
32 ; CHECK-NEXT: [[TMP5:%.*]] = phi <4 x i32> [ [[TMP1]], [[ENTRY]] ], [ [[TMP4]], [[FOR_BODY]] ]
33 ; CHECK-NEXT: [[TMP6:%.*]] = bitcast i32* [[A]] to <4 x i32>*
34 ; CHECK-NEXT: store <4 x i32> [[TMP5]], <4 x i32>* [[TMP6]], align 4
35 ; CHECK-NEXT: ret i32 undef
38 %0 = load i32, i32* %A, align 4
39 %arrayidx1 = getelementptr inbounds i32, i32* %A, i64 1
40 %1 = load i32, i32* %arrayidx1, align 4
41 %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 2
42 %2 = load i32, i32* %arrayidx2, align 4
43 %arrayidx3 = getelementptr inbounds i32, i32* %A, i64 3
44 %3 = load i32, i32* %arrayidx3, align 4
45 %arrayidx4 = getelementptr inbounds i32, i32* %A, i64 13
46 %4 = load i32, i32* %arrayidx4, align 4
47 %cmp24 = icmp sgt i32 %4, 0
48 br i1 %cmp24, label %for.body, label %for.end
50 for.body: ; preds = %entry, %for.body
51 %i.029 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
52 %a.028 = phi i32 [ %mul7, %for.body ], [ %3, %entry ]
53 %b.027 = phi i32 [ %mul6, %for.body ], [ %2, %entry ]
54 %g.026 = phi i32 [ %mul5, %for.body ], [ %1, %entry ]
55 %r.025 = phi i32 [ %mul, %for.body ], [ %0, %entry ]
56 %mul = mul nsw i32 %r.025, 18
57 %mul5 = mul nsw i32 %g.026, 19
58 %mul6 = mul nsw i32 %b.027, 12
59 %mul7 = mul nsw i32 %a.028, 9
60 %inc = add nsw i32 %i.029, 1
61 %cmp = icmp slt i32 %inc, %4
62 br i1 %cmp, label %for.body, label %for.end
64 for.end: ; preds = %for.body, %entry
65 %a.0.lcssa = phi i32 [ %3, %entry ], [ %mul7, %for.body ]
66 %b.0.lcssa = phi i32 [ %2, %entry ], [ %mul6, %for.body ]
67 %g.0.lcssa = phi i32 [ %1, %entry ], [ %mul5, %for.body ]
68 %r.0.lcssa = phi i32 [ %0, %entry ], [ %mul, %for.body ]
69 store i32 %r.0.lcssa, i32* %A, align 4
70 store i32 %g.0.lcssa, i32* %arrayidx1, align 4
71 store i32 %b.0.lcssa, i32* %arrayidx2, align 4
72 store i32 %a.0.lcssa, i32* %arrayidx3, align 4