1; RUN: llc < %s -mcpu=ppc | FileCheck %s 2 3target datalayout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32" 4target triple = "powerpc-unknown-linux-gnu" 5 6define i64 @foo(i64* nocapture %n, i64 %d) nounwind readonly { 7entry: 8 br label %for.body 9 10for.body: ; preds = %for.body, %entry 11 %i.06 = phi i32 [ 0, %entry ], [ %inc, %for.body ] 12 %x.05 = phi i64 [ 0, %entry ], [ %conv1, %for.body ] 13 %arrayidx = getelementptr inbounds i64, i64* %n, i32 %i.06 14 %0 = load i64, i64* %arrayidx, align 8 15 %conv = udiv i64 %x.05, %d 16 %conv1 = add i64 %conv, %0 17 %inc = add nsw i32 %i.06, 1 18 %exitcond = icmp eq i32 %inc, 2048 19 br i1 %exitcond, label %for.end, label %for.body 20 21for.end: ; preds = %for.body 22 ret i64 %conv1 23} 24 25; CHECK: @foo 26; CHECK-NOT: mtctr 27 28define i64 @foo2(i64* nocapture %n, i64 %d) nounwind readonly { 29entry: 30 br label %for.body 31 32for.body: ; preds = %for.body, %entry 33 %i.06 = phi i32 [ 0, %entry ], [ %inc, %for.body ] 34 %x.05 = phi i64 [ 0, %entry ], [ %conv1, %for.body ] 35 %arrayidx = getelementptr inbounds i64, i64* %n, i32 %i.06 36 %0 = load i64, i64* %arrayidx, align 8 37 %conv = sdiv i64 %x.05, %d 38 %conv1 = add i64 %conv, %0 39 %inc = add nsw i32 %i.06, 1 40 %exitcond = icmp eq i32 %inc, 2048 41 br i1 %exitcond, label %for.end, label %for.body 42 43for.end: ; preds = %for.body 44 ret i64 %conv1 45} 46 47; CHECK: @foo2 48; CHECK-NOT: mtctr 49 50define i64 @foo3(i64* nocapture %n, i64 %d) nounwind readonly { 51entry: 52 br label %for.body 53 54for.body: ; preds = %for.body, %entry 55 %i.06 = phi i32 [ 0, %entry ], [ %inc, %for.body ] 56 %x.05 = phi i64 [ 0, %entry ], [ %conv1, %for.body ] 57 %arrayidx = getelementptr inbounds i64, i64* %n, i32 %i.06 58 %0 = load i64, i64* %arrayidx, align 8 59 %conv = urem i64 %x.05, %d 60 %conv1 = add i64 %conv, %0 61 %inc = add nsw i32 %i.06, 1 62 %exitcond = icmp eq i32 %inc, 2048 63 br i1 %exitcond, label %for.end, label %for.body 64 65for.end: ; preds = %for.body 66 ret i64 %conv1 67} 68 69; CHECK: @foo3 70; CHECK-NOT: mtctr 71 72define i64 @foo4(i64* nocapture %n, i64 %d) nounwind readonly { 73entry: 74 br label %for.body 75 76for.body: ; preds = %for.body, %entry 77 %i.06 = phi i32 [ 0, %entry ], [ %inc, %for.body ] 78 %x.05 = phi i64 [ 0, %entry ], [ %conv1, %for.body ] 79 %arrayidx = getelementptr inbounds i64, i64* %n, i32 %i.06 80 %0 = load i64, i64* %arrayidx, align 8 81 %conv = srem i64 %x.05, %d 82 %conv1 = add i64 %conv, %0 83 %inc = add nsw i32 %i.06, 1 84 %exitcond = icmp eq i32 %inc, 2048 85 br i1 %exitcond, label %for.end, label %for.body 86 87for.end: ; preds = %for.body 88 ret i64 %conv1 89} 90 91; CHECK: @foo4 92; CHECK-NOT: mtctr 93 94