xref: /aosp_15_r20/external/llvm/test/CodeGen/Mips/call-optimization.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mipsel -disable-mips-delay-filler -relocation-model=pic < %s | \
2*9880d681SAndroid Build Coastguard Worker; RUN:  FileCheck %s -check-prefix=O32
3*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mipsel -mips-load-target-from-got=false \
4*9880d681SAndroid Build Coastguard Worker; RUN:  -disable-mips-delay-filler -relocation-model=pic < %s | FileCheck %s -check-prefix=O32-LOADTGT
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker@gd1 = common global double 0.000000e+00, align 8
7*9880d681SAndroid Build Coastguard Worker@gd2 = common global double 0.000000e+00, align 8
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker; O32-LABEL: caller3:
10*9880d681SAndroid Build Coastguard Worker; O32-DAG:   lw $25, %call16(callee3)
11*9880d681SAndroid Build Coastguard Worker; O32-DAG:   move $gp
12*9880d681SAndroid Build Coastguard Worker; O32:       jalr $25
13*9880d681SAndroid Build Coastguard Worker; O32-NOT:   move $gp
14*9880d681SAndroid Build Coastguard Worker; O32:       lw $25, %call16(callee3)
15*9880d681SAndroid Build Coastguard Worker; O32-NOT:   move $gp
16*9880d681SAndroid Build Coastguard Worker; O32:       jalr $25
17*9880d681SAndroid Build Coastguard Worker; O32-NOT:   move $gp
18*9880d681SAndroid Build Coastguard Worker; O32:       lw $25, %call16(callee3)
19*9880d681SAndroid Build Coastguard Worker; O32-NOT:   move $gp
20*9880d681SAndroid Build Coastguard Worker; O32:       jalr $25
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT-LABEL: caller3:
23*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT-DAG:   lw $25, %call16(callee3)
24*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT-DAG:   move $gp
25*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT:       jalr $25
26*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT-NOT:   move $gp
27*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT:       move $25
28*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT-NOT:   move $gp
29*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT:       jalr $25
30*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT-NOT:   move $gp
31*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT:       move $25
32*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT-NOT:   move $gp
33*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT:       jalr $25
34*9880d681SAndroid Build Coastguard Worker
35*9880d681SAndroid Build Coastguard Workerdefine void @caller3(i32 %n) {
36*9880d681SAndroid Build Coastguard Workerentry:
37*9880d681SAndroid Build Coastguard Worker  tail call void @callee3()
38*9880d681SAndroid Build Coastguard Worker  tail call void @callee3()
39*9880d681SAndroid Build Coastguard Worker  %tobool1 = icmp eq i32 %n, 0
40*9880d681SAndroid Build Coastguard Worker  br i1 %tobool1, label %while.end, label %while.body
41*9880d681SAndroid Build Coastguard Worker
42*9880d681SAndroid Build Coastguard Workerwhile.body:
43*9880d681SAndroid Build Coastguard Worker  %n.addr.02 = phi i32 [ %dec, %while.body ], [ %n, %entry ]
44*9880d681SAndroid Build Coastguard Worker  %dec = add nsw i32 %n.addr.02, -1
45*9880d681SAndroid Build Coastguard Worker  tail call void @callee3()
46*9880d681SAndroid Build Coastguard Worker  %tobool = icmp eq i32 %dec, 0
47*9880d681SAndroid Build Coastguard Worker  br i1 %tobool, label %while.end, label %while.body
48*9880d681SAndroid Build Coastguard Worker
49*9880d681SAndroid Build Coastguard Workerwhile.end:
50*9880d681SAndroid Build Coastguard Worker  ret void
51*9880d681SAndroid Build Coastguard Worker}
52*9880d681SAndroid Build Coastguard Worker
53*9880d681SAndroid Build Coastguard Workerdeclare void @callee3()
54*9880d681SAndroid Build Coastguard Worker
55*9880d681SAndroid Build Coastguard Worker; O32-LABEL: caller4:
56*9880d681SAndroid Build Coastguard Worker; O32-DAG:   lw $25, %call16(ceil)
57*9880d681SAndroid Build Coastguard Worker; O32-DAG:   move $gp
58*9880d681SAndroid Build Coastguard Worker; O32:       jalr $25
59*9880d681SAndroid Build Coastguard Worker; O32-NOT:   move $gp
60*9880d681SAndroid Build Coastguard Worker; O32:       lw $25, %call16(ceil)
61*9880d681SAndroid Build Coastguard Worker; O32-NOT:   move $gp
62*9880d681SAndroid Build Coastguard Worker; O32:       jalr $25
63*9880d681SAndroid Build Coastguard Worker; O32-NOT:   move $gp
64*9880d681SAndroid Build Coastguard Worker; O32:       lw $25, %call16(ceil)
65*9880d681SAndroid Build Coastguard Worker; O32-NOT:   move $gp
66*9880d681SAndroid Build Coastguard Worker; O32:       jalr $25
67*9880d681SAndroid Build Coastguard Worker
68*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT-LABEL: caller4:
69*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT-DAG:   lw $25, %call16(ceil)
70*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT-DAG:   move $gp
71*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT:       jalr $25
72*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT-NOT:   move $gp
73*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT:       move $25
74*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT-NOT:   move $gp
75*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT:       jalr $25
76*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT-NOT:   move $gp
77*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT:       move $25
78*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT-NOT:   move $gp
79*9880d681SAndroid Build Coastguard Worker; O32-LOADTGT:       jalr $25
80*9880d681SAndroid Build Coastguard Worker
81*9880d681SAndroid Build Coastguard Workerdefine void @caller4(double %d) {
82*9880d681SAndroid Build Coastguard Workerentry:
83*9880d681SAndroid Build Coastguard Worker  %call = tail call double @ceil(double %d)
84*9880d681SAndroid Build Coastguard Worker  %call1 = tail call double @ceil(double %call)
85*9880d681SAndroid Build Coastguard Worker  store double %call1, double* @gd2, align 8
86*9880d681SAndroid Build Coastguard Worker  %call2 = tail call double @ceil(double %call1)
87*9880d681SAndroid Build Coastguard Worker  store double %call2, double* @gd1, align 8
88*9880d681SAndroid Build Coastguard Worker  ret void
89*9880d681SAndroid Build Coastguard Worker}
90*9880d681SAndroid Build Coastguard Worker
91*9880d681SAndroid Build Coastguard Workerdeclare double @ceil(double)
92