1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
3 ; RUN: -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | FileCheck %s
5 ; The tests check the behavior of the tail call decision when the callee is speculatable.
7 ; Callee should be tail called in this function since it is at a tail call position.
8 define dso_local double @speculatable_callee_return_use_only (ptr nocapture %res, double %a) #0 {
9 ; CHECK-LABEL: speculatable_callee_return_use_only:
10 ; CHECK: # %bb.0: # %entry
11 ; CHECK-NEXT: b callee
12 ; CHECK-NEXT: #TC_RETURNd8 callee 0
14 %value = tail call double @callee(double %a) #2
18 ; Callee should not be tail called since it is not at a tail call position.
19 define dso_local void @speculatable_callee_non_return_use_only (ptr nocapture %res, double %a) #0 {
20 ; CHECK-LABEL: speculatable_callee_non_return_use_only:
21 ; CHECK: # %bb.0: # %entry
23 ; CHECK-NEXT: std r30, -16(r1) # 8-byte Folded Spill
24 ; CHECK-NEXT: stdu r1, -48(r1)
25 ; CHECK-NEXT: std r0, 64(r1)
26 ; CHECK-NEXT: mr r30, r3
27 ; CHECK-NEXT: bl callee
28 ; CHECK-NEXT: stfd f1, 0(r30)
29 ; CHECK-NEXT: addi r1, r1, 48
30 ; CHECK-NEXT: ld r0, 16(r1)
31 ; CHECK-NEXT: ld r30, -16(r1) # 8-byte Folded Reload
35 %call = tail call double @callee(double %a) #2
36 store double %call, ptr %res, align 8
40 ; Callee should not be tail called since it is not at a tail call position.
41 define dso_local double @speculatable_callee_multi_use (ptr nocapture %res, double %a) #0 {
42 ; CHECK-LABEL: speculatable_callee_multi_use:
43 ; CHECK: # %bb.0: # %entry
45 ; CHECK-NEXT: std r30, -16(r1) # 8-byte Folded Spill
46 ; CHECK-NEXT: stdu r1, -48(r1)
47 ; CHECK-NEXT: std r0, 64(r1)
48 ; CHECK-NEXT: mr r30, r3
49 ; CHECK-NEXT: bl callee
50 ; CHECK-NEXT: stfd f1, 0(r30)
51 ; CHECK-NEXT: addi r1, r1, 48
52 ; CHECK-NEXT: ld r0, 16(r1)
53 ; CHECK-NEXT: ld r30, -16(r1) # 8-byte Folded Reload
57 %call = tail call double @callee(double %a) #2
58 store double %call, ptr %res, align 8
62 ; Callee should not be tail called since it is not at a tail call position.
63 ; FIXME: A speculatable callee can be tail called if it is moved into a valid tail call position.
64 define dso_local double @speculatable_callee_intermediate_instructions (ptr nocapture %res, double %a) #0 {
65 ; CHECK-LABEL: speculatable_callee_intermediate_instructions:
66 ; CHECK: # %bb.0: # %entry
68 ; CHECK-NEXT: std r30, -16(r1) # 8-byte Folded Spill
69 ; CHECK-NEXT: stdu r1, -48(r1)
70 ; CHECK-NEXT: std r0, 64(r1)
71 ; CHECK-NEXT: mr r30, r3
72 ; CHECK-NEXT: bl callee
73 ; CHECK-NEXT: lis r3, 4101
74 ; CHECK-NEXT: ori r3, r3, 13107
75 ; CHECK-NEXT: rldic r3, r3, 34, 1
76 ; CHECK-NEXT: oris r3, r3, 52428
77 ; CHECK-NEXT: ori r3, r3, 52429
78 ; CHECK-NEXT: std r3, 0(r30)
79 ; CHECK-NEXT: addi r1, r1, 48
80 ; CHECK-NEXT: ld r0, 16(r1)
81 ; CHECK-NEXT: ld r30, -16(r1) # 8-byte Folded Reload
86 %call = tail call double @callee(double %a) #2
87 store double 5.2, ptr %res, align 8
92 define dso_local double @callee(double) #1 {
93 ; CHECK-LABEL: callee:
95 ; CHECK-NEXT: addis r3, r2, .LCPI4_0@toc@ha
96 ; CHECK-NEXT: lfs f1, .LCPI4_0@toc@l(r3)
101 attributes #0 = { nounwind }
102 attributes #1 = { readnone speculatable }
103 attributes #2 = { nounwind noinline }