1; Check that a callee-saved register will be saved correctly if
2; the predicate-to-GPR spilling code uses it.
3;
4; RUN: llc -march=hexagon < %s | FileCheck %s
5;
6; We expect to spill p0 into a general-purpose register and keep it there,
7; without adding an extra spill of that register.
8;
9; CHECK: PredSpill:
10; CHECK: memd(r29{{.*}}) = r17:16
11; CHECK-DAG: r{{[0-9]+}} = p0
12; CHECK-DAG: p0 = r{{[0-9]+}}
13; CHECK-NOT: = memw(r29
14;
15
16define void @PredSpill() {
17entry:
18  br i1 undef, label %if.then, label %if.else.14
19
20if.then:                                          ; preds = %entry
21  br i1 undef, label %if.end.57, label %if.else
22
23if.else:                                          ; preds = %if.then
24  unreachable
25
26if.else.14:                                       ; preds = %entry
27  br i1 undef, label %if.then.17, label %if.end.57
28
29if.then.17:                                       ; preds = %if.else.14
30  br i1 undef, label %if.end.57, label %if.then.20
31
32if.then.20:                                       ; preds = %if.then.17
33  %call21 = tail call i32 @myfun()
34  %tobool22 = icmp eq i32 %call21, 0
35  %0 = tail call i32 @myfun()
36  br i1 %tobool22, label %if.else.42, label %if.then.23
37
38if.then.23:                                       ; preds = %if.then.20
39  unreachable
40
41if.else.42:                                       ; preds = %if.then.20
42  ret void
43
44if.end.57:                                        ; preds = %if.then.17, %if.else.14, %if.then
45  ret void
46}
47
48declare i32 @myfun()
49
50