1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -relocation-model=pic -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr9 < %s | FileCheck -check-prefix=CHECK-P9 %s
3 ; RUN: llc -relocation-model=pic -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 < %s | FileCheck -check-prefix=CHECK-P8 %s
5 ; As the constant could be represented as float, a float is
6 ; loaded from constant pool.
7 define double @doubleConstant1() {
8 ; CHECK-P9-LABEL: doubleConstant1:
10 ; CHECK-P9-NEXT: vspltisw 2, 14
11 ; CHECK-P9-NEXT: xvcvsxwdp 1, 34
12 ; CHECK-P9-NEXT: # kill: def $f1 killed $f1 killed $vsl1
15 ; CHECK-P8-LABEL: doubleConstant1:
17 ; CHECK-P8-NEXT: vspltisw 2, 14
18 ; CHECK-P8-NEXT: xvcvsxwdp 1, 34
19 ; CHECK-P8-NEXT: # kill: def $f1 killed $f1 killed $vsl1
21 ret double 1.400000e+01
24 ; As the constant couldn't be represented as float, a double is
25 ; loaded from constant pool.
26 define double @doubleConstant2() {
27 ; CHECK-P9-LABEL: doubleConstant2:
29 ; CHECK-P9-NEXT: addis 3, 2, .LCPI1_0@toc@ha
30 ; CHECK-P9-NEXT: lfd 1, .LCPI1_0@toc@l(3)
33 ; CHECK-P8-LABEL: doubleConstant2:
35 ; CHECK-P8-NEXT: addis 3, 2, .LCPI1_0@toc@ha
36 ; CHECK-P8-NEXT: lfd 1, .LCPI1_0@toc@l(3)
38 ret double 2.408904e+01
41 @FArr = hidden local_unnamed_addr global [10 x float] zeroinitializer, align 4
43 define float @floatConstantArray() local_unnamed_addr {
44 ; CHECK-P9-LABEL: floatConstantArray:
46 ; CHECK-P9-NEXT: addis 3, 2, FArr@toc@ha+12
47 ; CHECK-P9-NEXT: lfs 0, FArr@toc@l+12(3)
48 ; CHECK-P9-NEXT: addis 3, 2, .LCPI2_0@toc@ha
49 ; CHECK-P9-NEXT: lfs 1, .LCPI2_0@toc@l(3)
50 ; CHECK-P9-NEXT: xsaddsp 1, 0, 1
53 ; CHECK-P8-LABEL: floatConstantArray:
55 ; CHECK-P8-NEXT: addis 3, 2, FArr@toc@ha+12
56 ; CHECK-P8-NEXT: lfs 0, FArr@toc@l+12(3)
57 ; CHECK-P8-NEXT: addis 3, 2, .LCPI2_0@toc@ha
58 ; CHECK-P8-NEXT: lfs 1, .LCPI2_0@toc@l(3)
59 ; CHECK-P8-NEXT: xsaddsp 1, 0, 1
61 %1 = load float, ptr getelementptr inbounds ([10 x float], ptr @FArr, i64 0, i64 3), align 4
62 %2 = fadd float %1, 0x400B333340000000
66 define float @floatConstant() {
67 ; CHECK-P9-LABEL: floatConstant:
69 ; CHECK-P9-NEXT: addis 3, 2, .LCPI3_0@toc@ha
70 ; CHECK-P9-NEXT: lfs 1, .LCPI3_0@toc@l(3)
73 ; CHECK-P8-LABEL: floatConstant:
75 ; CHECK-P8-NEXT: addis 3, 2, .LCPI3_0@toc@ha
76 ; CHECK-P8-NEXT: lfs 1, .LCPI3_0@toc@l(3)
78 ret float 0x400470A3E0000000
81 ; llvm put the hidden globals into the TOC table.
82 ; TODO - do some analysis and decide which globals could be put into TOC.
83 @d = hidden local_unnamed_addr global [200 x double] zeroinitializer, align 8
85 define double @doubleConstantArray() {
86 ; CHECK-P9-LABEL: doubleConstantArray:
88 ; CHECK-P9-NEXT: addis 3, 2, d@toc@ha+24
89 ; CHECK-P9-NEXT: lfd 0, d@toc@l+24(3)
90 ; CHECK-P9-NEXT: addis 3, 2, .LCPI4_0@toc@ha
91 ; CHECK-P9-NEXT: lfd 1, .LCPI4_0@toc@l(3)
92 ; CHECK-P9-NEXT: xsadddp 1, 0, 1
95 ; CHECK-P8-LABEL: doubleConstantArray:
97 ; CHECK-P8-NEXT: addis 3, 2, d@toc@ha+24
98 ; CHECK-P8-NEXT: lfd 0, d@toc@l+24(3)
99 ; CHECK-P8-NEXT: addis 3, 2, .LCPI4_0@toc@ha
100 ; CHECK-P8-NEXT: lfd 1, .LCPI4_0@toc@l(3)
101 ; CHECK-P8-NEXT: xsadddp 1, 0, 1
103 %1 = load double, ptr getelementptr inbounds ([200 x double], ptr @d, i64 0, i64 3), align 8
104 %2 = fadd double %1, 6.880000e+00
108 @arr = hidden local_unnamed_addr global [20000 x double] zeroinitializer, align 8
110 ; Access an element with an offset that doesn't fit in the displacement field of LFD.
111 define double @doubleLargeConstantArray() {
112 ; CHECK-P9-LABEL: doubleLargeConstantArray:
114 ; CHECK-P9-NEXT: addis 3, 2, arr@toc@ha
115 ; CHECK-P9-NEXT: li 4, 0
116 ; CHECK-P9-NEXT: addi 3, 3, arr@toc@l
117 ; CHECK-P9-NEXT: ori 4, 4, 32768
118 ; CHECK-P9-NEXT: lfdx 0, 3, 4
119 ; CHECK-P9-NEXT: addis 3, 2, .LCPI5_0@toc@ha
120 ; CHECK-P9-NEXT: lfd 1, .LCPI5_0@toc@l(3)
121 ; CHECK-P9-NEXT: xsadddp 1, 0, 1
124 ; CHECK-P8-LABEL: doubleLargeConstantArray:
126 ; CHECK-P8-NEXT: addis 3, 2, arr@toc@ha
127 ; CHECK-P8-NEXT: li 4, 0
128 ; CHECK-P8-NEXT: addi 3, 3, arr@toc@l
129 ; CHECK-P8-NEXT: ori 4, 4, 32768
130 ; CHECK-P8-NEXT: lfdx 0, 3, 4
131 ; CHECK-P8-NEXT: addis 3, 2, .LCPI5_0@toc@ha
132 ; CHECK-P8-NEXT: lfd 1, .LCPI5_0@toc@l(3)
133 ; CHECK-P8-NEXT: xsadddp 1, 0, 1
135 %1 = load double, ptr getelementptr inbounds ([20000 x double], ptr @arr, i64 0, i64 4096), align 8
136 %2 = fadd double %1, 6.880000e+00
140 @vec_arr = global [10 x <4 x i32>] zeroinitializer, align 16
142 define <4 x i32> @vectorArray() #0 {
143 ; CHECK-P9-LABEL: vectorArray:
144 ; CHECK-P9: # %bb.0: # %entry
145 ; CHECK-P9-NEXT: addis 3, 2, .LC0@toc@ha
146 ; CHECK-P9-NEXT: ld 3, .LC0@toc@l(3)
147 ; CHECK-P9-NEXT: lxv 34, 32(3)
150 ; CHECK-P8-LABEL: vectorArray:
151 ; CHECK-P8: # %bb.0: # %entry
152 ; CHECK-P8-NEXT: addis 3, 2, .LC0@toc@ha
153 ; CHECK-P8-NEXT: ld 3, .LC0@toc@l(3)
154 ; CHECK-P8-NEXT: addi 3, 3, 32
155 ; CHECK-P8-NEXT: lxvd2x 0, 0, 3
156 ; CHECK-P8-NEXT: xxswapd 34, 0
159 %0 = load <4 x i32>, ptr getelementptr inbounds ([10 x <4 x i32>], ptr @vec_arr, i64 0, i64 2), align 16