1 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
2 ; RUN: -mcpu=pwr10 -ppc-asm-full-reg-names < %s \
3 ; RUN: | FileCheck %s --check-prefixes=CHECK-S,CHECK-ALL
4 ; RUN: llc -verify-machineinstrs -target-abi=elfv2 -mtriple=powerpc64-- \
5 ; RUN: -mcpu=pwr10 -ppc-asm-full-reg-names < %s \
6 ; RUN: | FileCheck %s --check-prefixes=CHECK-S,CHECK-ALL
7 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
8 ; RUN: -mcpu=pwr9 -ppc-asm-full-reg-names < %s \
9 ; RUN: | FileCheck %s --check-prefixes=CHECK-P9,CHECK-ALL
10 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
11 ; RUN: -mcpu=pwr9 --code-model=large -ppc-asm-full-reg-names < %s \
12 ; RUN: | FileCheck %s --check-prefixes=CHECK-LARGE,CHECK-ALL
14 @global_int = common dso_local local_unnamed_addr global i32 0, align 4
16 define dso_local signext i32 @NoTOC() local_unnamed_addr {
17 ; CHECK-ALL-LABEL: NoTOC:
18 ; CHECK-S-NOT: .localentry
25 define dso_local signext i32 @AsmClobberX2(i32 signext %a, i32 signext %b) local_unnamed_addr {
26 ; CHECK-ALL-LABEL: AsmClobberX2:
27 ; CHECK-S: .localentry AsmClobberX2, 1
28 ; CHECK-S: add r3, r4, r3
31 ; CHECK-S-NEXT: #NO_APP
34 %add = add nsw i32 %b, %a
35 tail call void asm sideeffect "nop", "~{r2}"()
39 ; FIXME: This is actually a test case that shows a bug. On power9 and earlier
40 ; this test should not compile. On later CPUs (like this test) the @toc
41 ; should be replaced with @pcrel and we won't need R2 and so the problem
43 define dso_local signext i32 @AsmClobberX2WithTOC(i32 signext %a, i32 signext %b) local_unnamed_addr {
44 ; CHECK-ALL-LABEL: AsmClobberX2WithTOC:
45 ; CHECK-LARGE: ld r2, .Lfunc_toc2-.Lfunc_gep2(r12)
46 ; CHECK-LARGE: add r2, r2, r12
47 ; CHECK-S: .localentry AsmClobberX2WithTOC
49 ; CHECK-S-NEXT: li r2, 0
50 ; CHECK-S-NEXT: #NO_APP
51 ; CHECK-S-NEXT: plwz r5, global_int@PCREL(0), 1
52 ; CHECK-S-NEXT: add r3, r4, r3
53 ; CHECK-S-NEXT: add r3, r3, r5
54 ; CHECK-S-NEXT: extsw r3, r3
57 %add = add nsw i32 %b, %a
58 tail call void asm sideeffect "li 2, 0", "~{r2}"()
59 %0 = load i32, ptr @global_int, align 4
60 %add1 = add nsw i32 %add, %0
64 define dso_local signext i32 @AsmClobberX5(i32 signext %a, i32 signext %b) local_unnamed_addr {
65 ; CHECK-ALL-LABEL: AsmClobberX5:
66 ; CHECK-S: .localentry AsmClobberX5, 1
67 ; CHECK-P9-NOT: .localentry
68 ; CHECK-ALL: # %bb.0: # %entry
69 ; CHECK-S-NEXT: add r3, r4, r3
72 ; CHECK-S-NEXT: #NO_APP
73 ; CHECK-S-NEXT: extsw r3, r3
76 %add = add nsw i32 %b, %a
77 tail call void asm sideeffect "nop", "~{r5}"()
81 ; Clobber all GPRs except R2.
82 define dso_local signext i32 @AsmClobberNotR2(i32 signext %a, i32 signext %b) local_unnamed_addr {
83 ; CHECK-ALL-LABEL: AsmClobberNotR2:
84 ; CHECK-S: .localentry AsmClobberNotR2, 1
85 ; CHECK-P9-NOT: .localentry
86 ; CHECK-S: add r3, r4, r3
87 ; CHECK-S: stw r3, -148(r1) # 4-byte Folded Spill
90 ; CHECK-S-NEXT: #NO_APP
91 ; CHECK-S-NEXT: lwz r3, -148(r1) # 4-byte Folded Reload
94 %add = add nsw i32 %b, %a
95 tail call void asm sideeffect "nop", "~{r0},~{r1},~{r3},~{r4},~{r5},~{r6},~{r7},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{r16},~{r17},~{r18},~{r19},~{r20},~{r21},~{r22},~{r23},~{r24},~{r25},~{r26},~{r27},~{r28},~{r29},~{r30},~{r31}"()
99 ; Increase register pressure enough to force the register allocator to
101 define dso_local signext i32 @X2IsCallerSaved(i32 signext %a, i32 signext %b, i32 signext %c, i32 signext %d, i32 signext %e, i32 signext %f, i32 signext %g, i32 signext %h) local_unnamed_addr {
102 ; CHECK-ALL-LABEL: X2IsCallerSaved:
103 ; CHECK-S: .localentry X2IsCallerSaved, 1
104 ; CHECK-P9-NOT: .localentry
105 ; CHECK-ALL: # %bb.0: # %entry
106 ; CHECK-S-NEXT: std r29, -24(r1) # 8-byte Folded Spill
107 ; CHECK-S-NEXT: std r30, -16(r1) # 8-byte Folded Spill
108 ; CHECK-S-NEXT: add r11, r4, r3
109 ; CHECK-S-NEXT: sub r29, r8, r9
110 ; CHECK-S-NEXT: add r9, r10, r9
111 ; CHECK-S-NEXT: sub r10, r10, r3
112 ; CHECK-S-NEXT: mullw r3, r4, r3
113 ; CHECK-S-NEXT: sub r12, r4, r5
114 ; CHECK-S-NEXT: add r0, r6, r5
115 ; CHECK-S-NEXT: sub r2, r6, r7
116 ; CHECK-S-NEXT: add r30, r8, r7
117 ; CHECK-S-NEXT: mullw r3, r3, r11
118 ; CHECK-S-NEXT: mullw r3, r3, r5
119 ; CHECK-S-NEXT: mullw r3, r3, r6
120 ; CHECK-S-NEXT: mullw r3, r3, r12
121 ; CHECK-S-NEXT: mullw r3, r3, r0
122 ; CHECK-S-NEXT: mullw r3, r3, r7
123 ; CHECK-S-NEXT: mullw r3, r3, r8
124 ; CHECK-S-NEXT: mullw r3, r3, r2
125 ; CHECK-S-NEXT: mullw r3, r3, r30
126 ; CHECK-S-NEXT: ld r30, -16(r1) # 8-byte Folded Reload
127 ; CHECK-S-NEXT: mullw r3, r3, r29
128 ; CHECK-S-NEXT: ld r29, -24(r1) # 8-byte Folded Reload
129 ; CHECK-S-NEXT: mullw r3, r3, r9
130 ; CHECK-S-NEXT: mullw r3, r3, r10
131 ; CHECK-S-NEXT: extsw r3, r3
134 %add = add nsw i32 %b, %a
135 %sub = sub nsw i32 %b, %c
136 %add1 = add nsw i32 %d, %c
137 %sub2 = sub nsw i32 %d, %e
138 %add3 = add nsw i32 %f, %e
139 %sub4 = sub nsw i32 %f, %g
140 %add5 = add nsw i32 %h, %g
141 %sub6 = sub nsw i32 %h, %a
142 %mul = mul i32 %b, %a
143 %mul7 = mul i32 %mul, %add
144 %mul8 = mul i32 %mul7, %c
145 %mul9 = mul i32 %mul8, %d
146 %mul10 = mul i32 %mul9, %sub
147 %mul11 = mul i32 %mul10, %add1
148 %mul12 = mul i32 %mul11, %e
149 %mul13 = mul i32 %mul12, %f
150 %mul14 = mul i32 %mul13, %sub2
151 %mul15 = mul i32 %mul14, %add3
152 %mul16 = mul i32 %mul15, %sub4
153 %mul17 = mul i32 %mul16, %add5
154 %mul18 = mul i32 %mul17, %sub6
159 define dso_local signext i32 @UsesX2AsTOC() local_unnamed_addr {
160 ; CHECK-ALL-LABEL: UsesX2AsTOC:
161 ; CHECK-LARGE: ld r2, .Lfunc_toc6-.Lfunc_gep6(r12)
162 ; CHECK-LARGE: add r2, r2, r12
163 ; CHECK-ALL: # %bb.0: # %entry
165 %0 = load i32, ptr @global_int, align 4
170 define dso_local double @UsesX2AsConstPoolTOC() local_unnamed_addr {
171 ; CHECK-ALL-LABEL: UsesX2AsConstPoolTOC:
172 ; CHECK-LARGE: ld r2, .Lfunc_toc7-.Lfunc_gep7(r12)
173 ; CHECK-LARGE: add r2, r2, r12
174 ; CHECK-S-NOT: .localentry
175 ; CHECK-ALL: # %bb.0: # %entry
176 ; CHECK-S-NEXT: xxsplti32dx vs1, 0, 1078011044
177 ; CHECK-S-NEXT: xxsplti32dx vs1, 1, -337824948
178 ; CHECK-S-NEXT: # kill: def $f1 killed $f1 killed $vsl1
181 ret double 0x404124A4EBDD334C