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
4 ; This IR comes from this C code:
6 ; for (int i = 0; i < 4; i++) {
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
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
26 define void @test(ptr %dst, ptr %src) {
30 for.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
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
41 exit: ; preds = %for.body
42 store i32 %i, ptr %dst