1 ; RUN: opt -passes=loop-unroll -mtriple=hexagon -S < %s | FileCheck %s
2 ; Check that the loop is peeled twice for Hexagon.
3 ; CHECK: while.body.peel
4 ; CHECK: while.body.peel2
6 %struct.STREAM = type { %union.anon, i32, i32 }
7 %union.anon = type { ptr }
9 define void @function(ptr nocapture readonly %b) local_unnamed_addr {
11 %bitPtr3 = getelementptr inbounds %struct.STREAM, ptr %b, i32 0, i32 2
12 %0 = load i32, ptr %bitPtr3, align 4
13 %cmp11 = icmp ult i32 %0, 32
14 br i1 %cmp11, label %while.body.preheader, label %do.end
17 %value2 = getelementptr inbounds %struct.STREAM, ptr %b, i32 0, i32 1
18 %1 = load i32, ptr %value2, align 4
19 %2 = load ptr, ptr %b, align 4
23 %bitPtr.014 = phi i32 [ %add, %while.body ], [ %0, %while.body.preheader ]
24 %value.013 = phi i32 [ %shl, %while.body ], [ %1, %while.body.preheader ]
25 %ptr.012 = phi ptr [ %incdec.ptr, %while.body ], [ %2, %while.body.preheader ]
26 %add = add nuw i32 %bitPtr.014, 8
27 %shr = lshr i32 %value.013, 24
28 %incdec.ptr = getelementptr inbounds i32, ptr %ptr.012, i32 1
29 store i32 %shr, ptr %ptr.012, align 4
30 %shl = shl i32 %value.013, 8
31 %cmp = icmp ult i32 %add, 17
32 br i1 %cmp, label %while.body, label %do.end