1 ; RUN: opt -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 { i32* }
9 define void @function(%struct.STREAM* nocapture readonly %b) local_unnamed_addr {
11 %bitPtr3 = getelementptr inbounds %struct.STREAM, %struct.STREAM* %b, i32 0, i32 2
12 %0 = load i32, i32* %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, %struct.STREAM* %b, i32 0, i32 1
18 %1 = load i32, i32* %value2, align 4
19 %w = getelementptr inbounds %struct.STREAM, %struct.STREAM* %b, i32 0, i32 0, i32 0
20 %2 = load i32*, i32** %w, align 4
24 %bitPtr.014 = phi i32 [ %add, %while.body ], [ %0, %while.body.preheader ]
25 %value.013 = phi i32 [ %shl, %while.body ], [ %1, %while.body.preheader ]
26 %ptr.012 = phi i32* [ %incdec.ptr, %while.body ], [ %2, %while.body.preheader ]
27 %add = add nuw i32 %bitPtr.014, 8
28 %shr = lshr i32 %value.013, 24
29 %incdec.ptr = getelementptr inbounds i32, i32* %ptr.012, i32 1
30 store i32 %shr, i32* %ptr.012, align 4
31 %shl = shl i32 %value.013, 8
32 %cmp = icmp ult i32 %add, 17
33 br i1 %cmp, label %while.body, label %do.end