1; RUN: opt < %s -passes=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(ptr noalias nocapture %a, ptr 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, ptr %b, i64 %indvars.iv 18 %tmp0 = load float, ptr %arrayidx, align 4 19 %add = fadd float %tmp0, 1.000000e+00 20 %arrayidx5 = getelementptr inbounds float, ptr %a, i64 %indvars.iv 21 store float %add, ptr %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, ptr %a, i32 %tmp0 33; CHECK-NOT: LV: Found uniform instruction: %i = phi i64 [ %i.next, %for.body ], [ 0, %entry ] 34 35define void @foo(ptr %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, ptr %a, i32 %tmp0 43 store i32 %tmp0, ptr %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 52; CHECK-LABEL: goo 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: %exitcond = icmp eq i64 %indvars.iv, 1599 55 56define i64 @goo(ptr noalias nocapture %a, ptr noalias nocapture readonly %b) #0 { 57entry: 58 br label %for.body 59 60for.body: ; preds = %for.body, %entry 61 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] 62 %arrayidx = getelementptr inbounds float, ptr %b, i64 %indvars.iv 63 %tmp0 = load float, ptr %arrayidx, align 4 64 %add = fadd float %tmp0, 1.000000e+00 65 %arrayidx5 = getelementptr inbounds float, ptr %a, i64 %indvars.iv 66 store float %add, ptr %arrayidx5, align 4 67 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 68 %exitcond = icmp eq i64 %indvars.iv, 1599 69 br i1 %exitcond, label %for.end, label %for.body 70 71for.end: ; preds = %for.body 72 %retval = add i64 %indvars.iv, %indvars.iv.next 73 ret i64 %retval 74} 75 76; CHECK-LABEL: PR38786 77; Check that first order recurrence phis (%phi32 and %phi64) are not uniform. 78; CHECK-NOT: LV: Found uniform instruction: %phi 79define void @PR38786(ptr %y, ptr %x, i64 %n) { 80entry: 81 br label %for.body 82 83for.body: 84 %phi32 = phi i32 [ 0, %entry ], [ %i32next, %for.body ] 85 %phi64 = phi i64 [ 0, %entry ], [ %i64next, %for.body ] 86 %i32next = add i32 %phi32, 1 87 %i64next = zext i32 %i32next to i64 88 %xip = getelementptr inbounds double, ptr %x, i64 %i64next 89 %yip = getelementptr inbounds double, ptr %y, i64 %phi64 90 %xi = load double, ptr %xip, align 8 91 store double %xi, ptr %yip, align 8 92 %cmp = icmp slt i64 %i64next, %n 93 br i1 %cmp, label %for.body, label %for.end 94 95for.end: 96 ret void 97} 98