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