1; RUN: opt -passes=loop-unroll -S -mtriple aarch64 -mcpu=cortex-a57 %s | FileCheck %s -check-prefix=UNROLL 2; RUN: opt -passes=loop-unroll -unroll-max-upperbound=0 -S -mtriple aarch64 -mcpu=cortex-a57 %s | FileCheck %s -check-prefix=NOUNROLL 3 4; This IR comes from this C code: 5; 6; for (int i = 0; i < 4; i++) { 7; if (src[i] == 1) { 8; *dst = i; 9; break; 10; } 11; } 12; 13; This test is meant to check that this loop is unrolled into four iterations. 14; Note that the load on the last iteration is dead and thus doesn't appear in 15; the output. 16 17; UNROLL-LABEL: @test 18; UNROLL: load i32, ptr 19; UNROLL: load i32, ptr 20; UNROLL: load i32, ptr 21; UNROLL-NOT: load i32, ptr 22; NOUNROLL-LABEL: @test 23; NOUNROLL: load i32, ptr 24; NOUNROLL-NOT: load i32, ptr 25 26define void @test(ptr %dst, ptr %src) { 27entry: 28 br label %for.body 29 30for.body: ; preds = %entry, %for.body 31 %i = phi i32 [ 0, %entry ], [ %inc, %for.body ] 32 %0 = sext i32 %i to i64 33 %1 = getelementptr inbounds i32, ptr %src, i64 %0 34 %2 = load i32, ptr %1 35 %inc = add nsw i32 %i, 1 36 %cmp1 = icmp slt i32 %inc, 4 37 %cmp3 = icmp eq i32 %2, 1 38 %or.cond = and i1 %cmp3, %cmp1 39 br i1 %or.cond, label %for.body, label %exit 40 41exit: ; preds = %for.body 42 store i32 %i, ptr %dst 43 ret void 44} 45