1 ; RUN: opt -loop-unroll -S -mtriple aarch64 -mcpu=cortex-a57 %s | FileCheck %s -check-prefix=UNROLL
2 ; RUN: opt -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, i32*
19 ; UNROLL: load i32, i32*
20 ; UNROLL: load i32, i32*
21 ; UNROLL-NOT: load i32, i32*
22 ; NOUNROLL-LABEL: @test
23 ; NOUNROLL: load i32, i32*
24 ; NOUNROLL-NOT: load i32, i32*
26 define void @test(i32* %dst, i32* %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, i32* %src, i64 %0
34 %2 = load i32, i32* %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
41 exit: ; preds = %for.body
42 store i32 %i, i32* %dst