1; RUN: opt < %s  -loop-vectorize -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7 -debug-only=loop-vectorize -S 2>&1 | FileCheck %s
2; REQUIRES: asserts
3target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4target triple = "x86_64-unknown-linux-gnu"
5
6; CHECK-LABEL: test
7; CHECK-DAG: LV: Found uniform instruction:   %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
8; CHECK-DAG: LV: Found uniform instruction:   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
9; CHECK-DAG: LV: Found uniform instruction:   %exitcond = icmp eq i64 %indvars.iv, 1599
10
11define void @test(float* noalias nocapture %a, float* noalias nocapture readonly %b) #0 {
12entry:
13  br label %for.body
14
15for.body:                                         ; preds = %for.body, %entry
16  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
17  %arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv
18  %tmp0 = load float, float* %arrayidx, align 4
19  %add = fadd float %tmp0, 1.000000e+00
20  %arrayidx5 = getelementptr inbounds float, float* %a, i64 %indvars.iv
21  store float %add, float* %arrayidx5, align 4
22  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
23  %exitcond = icmp eq i64 %indvars.iv, 1599
24  br i1 %exitcond, label %for.end, label %for.body
25
26for.end:                                          ; preds = %for.body
27  ret void
28}
29
30; CHECK-LABEL: foo
31; CHECK-DAG: LV: Found uniform instruction:   %cond = icmp eq i64 %i.next, %n
32; CHECK-DAG: LV: Found uniform instruction:   %tmp1 = getelementptr inbounds i32, i32* %a, i32 %tmp0
33; CHECK-NOT: LV: Found uniform instruction:   %i = phi i64 [ %i.next, %for.body ], [ 0, %entry ]
34
35define void @foo(i32* %a, i64 %n) {
36entry:
37  br label %for.body
38
39for.body:
40  %i = phi i64 [ %i.next, %for.body ], [ 0, %entry ]
41  %tmp0 = trunc i64 %i to i32
42  %tmp1 = getelementptr inbounds i32, i32* %a, i32 %tmp0
43  store i32 %tmp0, i32* %tmp1, align 4
44  %i.next = add nuw nsw i64 %i, 1
45  %cond = icmp eq i64 %i.next, %n
46  br i1 %cond, label %for.end, label %for.body
47
48for.end:
49  ret void
50}
51