1; RUN: opt -loop-unroll -S -mtriple arm-none-eabi -mcpu=cortex-m7 %s | FileCheck %s -check-prefix=UNROLL 2 3; This test is meant to check that this loop is unrolled into three iterations. 4 5; UNROLL-LABEL: @test 6; UNROLL: load i32, i32* 7; UNROLL: load i32, i32* 8; UNROLL: load i32, i32* 9; UNROLL-NOT: load i32, i32* 10 11define void @test(i32* %x, i32 %n) { 12entry: 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 17 18while.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 24 25if.then: ; preds = %while.body 26 store i32 0, i32* %x.addr.09, align 4 27 br label %if.end 28 29if.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 34 35while.end: ; preds = %if.end, %entry 36 ret void 37} 38 39