1 ; RUN: opt < %s -loop-vectorize -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7 -debug-only=loop-vectorize -S 2>&1 | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
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
11 define void @test(float* noalias nocapture %a, float* noalias nocapture readonly %b) #0 {
15 for.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
26 for.end: ; preds = %for.body
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 ]
35 define void @foo(i32* %a, i64 %n) {
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
53 ; Check %indvars.iv and %indvars.iv.next are uniform instructions even if they are used outside of loop.
54 ; CHECK-DAG: LV: Found uniform instruction: %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
55 ; CHECK-DAG: LV: Found uniform instruction: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
56 ; CHECK-DAG: LV: Found uniform instruction: %exitcond = icmp eq i64 %indvars.iv, 1599
58 define i64 @goo(float* noalias nocapture %a, float* noalias nocapture readonly %b) #0 {
62 for.body: ; preds = %for.body, %entry
63 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
64 %arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv
65 %tmp0 = load float, float* %arrayidx, align 4
66 %add = fadd float %tmp0, 1.000000e+00
67 %arrayidx5 = getelementptr inbounds float, float* %a, i64 %indvars.iv
68 store float %add, float* %arrayidx5, align 4
69 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
70 %exitcond = icmp eq i64 %indvars.iv, 1599
71 br i1 %exitcond, label %for.end, label %for.body
73 for.end: ; preds = %for.body
74 %retval = add i64 %indvars.iv, %indvars.iv.next
78 ; CHECK-LABEL: PR38786
79 ; Check that first order recurrence phis (%phi32 and %phi64) are not uniform.
80 ; CHECK-NOT: LV: Found uniform instruction: %phi
81 define void @PR38786(double* %y, double* %x, i64 %n) {
86 %phi32 = phi i32 [ 0, %entry ], [ %i32next, %for.body ]
87 %phi64 = phi i64 [ 0, %entry ], [ %i64next, %for.body ]
88 %i32next = add i32 %phi32, 1
89 %i64next = zext i32 %i32next to i64
90 %xip = getelementptr inbounds double, double* %x, i64 %i64next
91 %yip = getelementptr inbounds double, double* %y, i64 %phi64
92 %xi = load double, double* %xip, align 8
93 store double %xi, double* %yip, align 8
94 %cmp = icmp slt i64 %i64next, %n
95 br i1 %cmp, label %for.body, label %for.end