1target 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-v128:128:128-n32:64" 2target triple = "powerpc64-unknown-freebsd10.0" 3; RUN: llc < %s -march=ppc64 -relocation-model=pic | FileCheck %s 4 5@a = common global i32 0, align 4 6 7define void @test1(i32 %c) nounwind { 8entry: 9 br label %for.body 10 11for.body: ; preds = %for.body, %entry 12 %i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ] 13 %0 = load volatile i32, i32* @a, align 4 14 %add = add nsw i32 %0, %c 15 store volatile i32 %add, i32* @a, align 4 16 %inc = add nsw i32 %i.01, 1 17 %exitcond = icmp eq i32 %inc, 2048 18 br i1 %exitcond, label %for.end, label %for.body 19 20for.end: ; preds = %for.body 21 ret void 22; CHECK: @test1 23; CHECK-NOT: or 3, 3, 3 24; CHECK: mtctr 25; CHECK-NOT: addi {[0-9]+} 26; CHECK-NOT: cmplwi 27; CHECK: bdnz 28} 29 30define void @test2(i32 %c, i32 %d) nounwind { 31entry: 32 %cmp1 = icmp sgt i32 %d, 0 33 br i1 %cmp1, label %for.body, label %for.end 34 35for.body: ; preds = %entry, %for.body 36 %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ] 37 %0 = load volatile i32, i32* @a, align 4 38 %add = add nsw i32 %0, %c 39 store volatile i32 %add, i32* @a, align 4 40 %inc = add nsw i32 %i.02, 1 41 %exitcond = icmp eq i32 %inc, %d 42 br i1 %exitcond, label %for.end, label %for.body 43 44for.end: ; preds = %for.body, %entry 45 ret void 46; CHECK: @test2 47; CHECK: mtctr 48; CHECK-NOT: addi {[0-9]+} 49; CHECK-NOT: cmplwi 50; CHECK: bdnz 51} 52 53define void @test3(i32 %c, i32 %d) nounwind { 54entry: 55 %cmp1 = icmp sgt i32 %d, 0 56 br i1 %cmp1, label %for.body, label %for.end 57 58for.body: ; preds = %entry, %for.body 59 %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ] 60 %mul = mul nsw i32 %i.02, %c 61 %0 = load volatile i32, i32* @a, align 4 62 %add = add nsw i32 %0, %mul 63 store volatile i32 %add, i32* @a, align 4 64 %inc = add nsw i32 %i.02, 1 65 %exitcond = icmp eq i32 %inc, %d 66 br i1 %exitcond, label %for.end, label %for.body 67 68for.end: ; preds = %for.body, %entry 69 ret void 70; CHECK: @test3 71; CHECK: mtctr 72; CHECK-NOT: addi {[0-9]+} 73; CHECK-NOT: cmplwi 74; CHECK: bdnz 75} 76 77@tls_var = external thread_local global i8 78 79define i32 @test4(i32 %inp) { 80entry: 81 br label %for.body 82 83for.body: ; preds = %for.body, %entry 84 %phi = phi i32 [ %dec, %for.body ], [ %inp, %entry ] 85 %load = ptrtoint i8* @tls_var to i32 86 %val = add i32 %load, %phi 87 %dec = add i32 %phi, -1 88 %cmp = icmp sgt i32 %phi, 1 89 br i1 %cmp, label %for.body, label %return 90 91return: ; preds = %for.body 92 ret i32 %val 93; CHECK-LABEL: @test4 94; CHECK: mtctr 95; CHECK: bdnz 96; CHECK: __tls_get_addr 97} 98