1 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
2 ; RUN: -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | FileCheck %s
4 ; The tests check the behavior of the tail call decision when the callee is speculatable.
6 ; Callee should be tail called in this function since it is at a tail call position.
7 define dso_local double @speculatable_callee_return_use_only (double* nocapture %res, double %a) #0 {
8 ; CHECK-LABEL: speculatable_callee_return_use_only:
9 ; CHECK: # %bb.0: # %entry
10 ; CHECK-NEXT: b callee
12 %value = tail call double @callee(double %a) #2
16 ; Callee should not be tail called since it is not at a tail call position.
17 define dso_local void @speculatable_callee_non_return_use_only (double* nocapture %res, double %a) #0 {
18 ; CHECK-LABEL: speculatable_callee_non_return_use_only:
19 ; CHECK: # %bb.0: # %entry
21 ; CHECK-NEXT: std r30, -16(r1) # 8-byte Folded Spill
22 ; CHECK-NEXT: std r0, 16(r1)
23 ; CHECK-NEXT: stdu r1, -48(r1)
24 ; CHECK-NEXT: mr r30, r3
25 ; CHECK-NEXT: bl callee
26 ; CHECK-NEXT: stfd f1, 0(r30)
27 ; CHECK-NEXT: addi r1, r1, 48
28 ; CHECK-NEXT: ld r0, 16(r1)
29 ; CHECK-NEXT: ld r30, -16(r1) # 8-byte Folded Reload
33 %call = tail call double @callee(double %a) #2
34 store double %call, double* %res, align 8
38 ; Callee should not be tail called since it is not at a tail call position.
39 define dso_local double @speculatable_callee_multi_use (double* nocapture %res, double %a) #0 {
40 ; CHECK-LABEL: speculatable_callee_multi_use:
41 ; CHECK: # %bb.0: # %entry
43 ; CHECK-NEXT: std r30, -16(r1) # 8-byte Folded Spill
44 ; CHECK-NEXT: std r0, 16(r1)
45 ; CHECK-NEXT: stdu r1, -48(r1)
46 ; CHECK-NEXT: mr r30, r3
47 ; CHECK-NEXT: bl callee
48 ; CHECK-NEXT: stfd f1, 0(r30)
49 ; CHECK-NEXT: addi r1, r1, 48
50 ; CHECK-NEXT: ld r0, 16(r1)
51 ; CHECK-NEXT: ld r30, -16(r1) # 8-byte Folded Reload
55 %call = tail call double @callee(double %a) #2
56 store double %call, double* %res, align 8
60 ; Callee should not be tail called since it is not at a tail call position.
61 ; FIXME: A speculatable callee can be tail called if it is moved into a valid tail call position.
62 define dso_local double @speculatable_callee_intermediate_instructions (double* nocapture %res, double %a) #0 {
63 ; CHECK-LABEL: speculatable_callee_intermediate_instructions:
64 ; CHECK: # %bb.0: # %entry
66 ; CHECK-NEXT: std r30, -16(r1) # 8-byte Folded Spill
67 ; CHECK-NEXT: std r0, 16(r1)
68 ; CHECK-NEXT: stdu r1, -48(r1)
69 ; CHECK-NEXT: mr r30, r3
70 ; CHECK-NEXT: bl callee
71 ; CHECK-NEXT: lis r3, 4101
72 ; CHECK-NEXT: ori r3, r3, 13107
73 ; CHECK-NEXT: rldic r3, r3, 34, 1
74 ; CHECK-NEXT: oris r3, r3, 52428
75 ; CHECK-NEXT: ori r3, r3, 52429
76 ; CHECK-NEXT: std r3, 0(r30)
77 ; CHECK-NEXT: addi r1, r1, 48
78 ; CHECK-NEXT: ld r0, 16(r1)
79 ; CHECK-NEXT: ld r30, -16(r1) # 8-byte Folded Reload
84 %call = tail call double @callee(double %a) #2
85 store double 5.2, double* %res, align 8
90 define dso_local double @callee(double) #1 {
94 attributes #0 = { nounwind }
95 attributes #1 = { readnone speculatable }
96 attributes #2 = { nounwind noinline }