1; RUN: llc -march=hexagon -enable-pipeliner -hexagon-initial-cfg-cleanup=0 -stats -o /dev/null < %s 2>&1 -pipeliner-experimental-cg=true | FileCheck %s --check-prefix=STATS
2; REQUIRES: asserts
3
4; Check that we handle the case when a value is first defined in the loop.
5
6; STATS: 1 pipeliner        - Number of loops software pipelined
7
8; Function Attrs: nounwind
9define fastcc void @f0() #0 {
10b0:
11  br i1 undef, label %b7, label %b1
12
13b1:                                               ; preds = %b0
14  br i1 undef, label %b2, label %b4
15
16b2:                                               ; preds = %b1
17  %v0 = load i16, i16* undef, align 2
18  %v1 = load i16, i16* undef, align 2
19  br i1 undef, label %b5, label %b3
20
21b3:                                               ; preds = %b5, %b2
22  %v2 = phi i16 [ 0, %b2 ], [ %v14, %b5 ]
23  br label %b4
24
25b4:                                               ; preds = %b3, %b1
26  br i1 undef, label %b7, label %b6
27
28b5:                                               ; preds = %b5, %b2
29  %v3 = phi i16 [ %v5, %b5 ], [ undef, %b2 ]
30  %v4 = phi i16 [ 0, %b5 ], [ %v1, %b2 ]
31  %v5 = phi i16 [ 0, %b5 ], [ %v0, %b2 ]
32  %v6 = phi i16 [ %v4, %b5 ], [ undef, %b2 ]
33  %v7 = phi i16 [ %v14, %b5 ], [ 0, %b2 ]
34  %v8 = phi i32 [ %v15, %b5 ], [ undef, %b2 ]
35  %v9 = or i16 0, %v7
36  %v10 = lshr i16 %v3, 8
37  %v11 = lshr i16 %v6, 8
38  %v12 = or i16 %v11, %v9
39  %v13 = or i16 0, %v12
40  %v14 = or i16 %v10, %v13
41  %v15 = add nsw i32 %v8, -32
42  %v16 = icmp sgt i32 %v15, 31
43  br i1 %v16, label %b5, label %b3
44
45b6:                                               ; preds = %b4
46  br label %b7
47
48b7:                                               ; preds = %b6, %b4, %b0
49  ret void
50}
51
52attributes #0 = { nounwind "target-cpu"="hexagonv55" }
53