1 ; RUN: opt -loop-unroll -S -mtriple arm-none-eabi -mcpu=cortex-m7 %s | FileCheck %s -check-prefix=UNROLL
3 ; This test is meant to check that this loop is unrolled into three iterations.
6 ; UNROLL: load i32, i32*
7 ; UNROLL: load i32, i32*
8 ; UNROLL: load i32, i32*
9 ; UNROLL-NOT: load i32, i32*
11 define void @test(i32* %x, i32 %n) {
13 %sub = add nsw i32 %n, -1
14 %rem = srem i32 %sub, 4
15 %cmp7 = icmp sgt i32 %rem, 0
16 br i1 %cmp7, label %while.body, label %while.end
18 while.body: ; preds = %entry, %if.end
19 %x.addr.09 = phi i32* [ %incdec.ptr, %if.end ], [ %x, %entry ]
20 %n.addr.08 = phi i32 [ %dec, %if.end ], [ %rem, %entry ]
21 %0 = load i32, i32* %x.addr.09, align 4
22 %cmp1 = icmp slt i32 %0, 10
23 br i1 %cmp1, label %if.then, label %if.end
25 if.then: ; preds = %while.body
26 store i32 0, i32* %x.addr.09, align 4
29 if.end: ; preds = %if.then, %while.body
30 %incdec.ptr = getelementptr inbounds i32, i32* %x.addr.09, i32 1
31 %dec = add nsw i32 %n.addr.08, -1
32 %cmp = icmp sgt i32 %dec, 0
33 br i1 %cmp, label %while.body, label %while.end
35 while.end: ; preds = %if.end, %entry