45 lines · plain
1; RUN: opt -passes=loop-unroll -S -mtriple aarch64 -mcpu=cortex-a57 %s | FileCheck %s -check-prefix=UNROLL2; RUN: opt -passes=loop-unroll -unroll-max-upperbound=0 -S -mtriple aarch64 -mcpu=cortex-a57 %s | FileCheck %s -check-prefix=NOUNROLL3 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 in15; the output.16 17; UNROLL-LABEL: @test18; UNROLL: load i32, ptr19; UNROLL: load i32, ptr20; UNROLL: load i32, ptr21; UNROLL-NOT: load i32, ptr22; NOUNROLL-LABEL: @test23; NOUNROLL: load i32, ptr24; NOUNROLL-NOT: load i32, ptr25 26define void @test(ptr %dst, ptr %src) {27entry:28 br label %for.body29 30for.body: ; preds = %entry, %for.body31 %i = phi i32 [ 0, %entry ], [ %inc, %for.body ]32 %0 = sext i32 %i to i6433 %1 = getelementptr inbounds i32, ptr %src, i64 %034 %2 = load i32, ptr %135 %inc = add nsw i32 %i, 136 %cmp1 = icmp slt i32 %inc, 437 %cmp3 = icmp eq i32 %2, 138 %or.cond = and i1 %cmp3, %cmp139 br i1 %or.cond, label %for.body, label %exit40 41exit: ; preds = %for.body42 store i32 %i, ptr %dst43 ret void44}45