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
14 ; CHECK-P8-LABEL: doubleConstant1:
16 ; CHECK-P8-NEXT: vspltisw 2, 14
17 ; CHECK-P8-NEXT: xvcvsxwdp 1, 34
19 ret double 1.400000e+01
22 ; As the constant couldn't be represented as float, a double is
23 ; loaded from constant pool.
24 define double @doubleConstant2() {
25 ; CHECK-P9-LABEL: doubleConstant2:
27 ; CHECK-P9-NEXT: addis 3, 2, .LCPI1_0@toc@ha
28 ; CHECK-P9-NEXT: lfd 1, .LCPI1_0@toc@l(3)
31 ; CHECK-P8-LABEL: doubleConstant2:
33 ; CHECK-P8-NEXT: addis 3, 2, .LCPI1_0@toc@ha
34 ; CHECK-P8-NEXT: lfd 1, .LCPI1_0@toc@l(3)
36 ret double 2.408904e+01
39 @FArr = hidden local_unnamed_addr global [10 x float] zeroinitializer, align 4
41 define float @floatConstantArray() local_unnamed_addr {
42 ; CHECK-P9-LABEL: floatConstantArray:
44 ; CHECK-P9-NEXT: addis 3, 2, FArr@toc@ha+12
45 ; CHECK-P9-NEXT: lfs 0, FArr@toc@l+12(3)
46 ; CHECK-P9-NEXT: addis 3, 2, .LCPI2_0@toc@ha
47 ; CHECK-P9-NEXT: lfs 1, .LCPI2_0@toc@l(3)
48 ; CHECK-P9-NEXT: xsaddsp 1, 0, 1
51 ; CHECK-P8-LABEL: floatConstantArray:
53 ; CHECK-P8-NEXT: addis 3, 2, FArr@toc@ha+12
54 ; CHECK-P8-NEXT: lfs 0, FArr@toc@l+12(3)
55 ; CHECK-P8-NEXT: addis 3, 2, .LCPI2_0@toc@ha
56 ; CHECK-P8-NEXT: lfs 1, .LCPI2_0@toc@l(3)
57 ; CHECK-P8-NEXT: xsaddsp 1, 0, 1
59 %1 = load float, ptr getelementptr inbounds ([10 x float], ptr @FArr, i64 0, i64 3), align 4
60 %2 = fadd float %1, 0x400B333340000000
64 define float @floatConstant() {
65 ; CHECK-P9-LABEL: floatConstant:
67 ; CHECK-P9-NEXT: addis 3, 2, .LCPI3_0@toc@ha
68 ; CHECK-P9-NEXT: lfs 1, .LCPI3_0@toc@l(3)
71 ; CHECK-P8-LABEL: floatConstant:
73 ; CHECK-P8-NEXT: addis 3, 2, .LCPI3_0@toc@ha
74 ; CHECK-P8-NEXT: lfs 1, .LCPI3_0@toc@l(3)
76 ret float 0x400470A3E0000000
79 ; llvm put the hidden globals into the TOC table.
80 ; TODO - do some analysis and decide which globals could be put into TOC.
81 @d = hidden local_unnamed_addr global [200 x double] zeroinitializer, align 8
83 define double @doubleConstantArray() {
84 ; CHECK-P9-LABEL: doubleConstantArray:
86 ; CHECK-P9-NEXT: addis 3, 2, d@toc@ha+24
87 ; CHECK-P9-NEXT: lfd 0, d@toc@l+24(3)
88 ; CHECK-P9-NEXT: addis 3, 2, .LCPI4_0@toc@ha
89 ; CHECK-P9-NEXT: lfd 1, .LCPI4_0@toc@l(3)
90 ; CHECK-P9-NEXT: xsadddp 1, 0, 1
93 ; CHECK-P8-LABEL: doubleConstantArray:
95 ; CHECK-P8-NEXT: addis 3, 2, d@toc@ha+24
96 ; CHECK-P8-NEXT: lfd 0, d@toc@l+24(3)
97 ; CHECK-P8-NEXT: addis 3, 2, .LCPI4_0@toc@ha
98 ; CHECK-P8-NEXT: lfd 1, .LCPI4_0@toc@l(3)
99 ; CHECK-P8-NEXT: xsadddp 1, 0, 1
101 %1 = load double, ptr getelementptr inbounds ([200 x double], ptr @d, i64 0, i64 3), align 8
102 %2 = fadd double %1, 6.880000e+00
106 @arr = hidden local_unnamed_addr global [20000 x double] zeroinitializer, align 8
108 ; Access an element with an offset that doesn't fit in the displacement field of LFD.
109 define double @doubleLargeConstantArray() {
110 ; CHECK-P9-LABEL: doubleLargeConstantArray:
112 ; CHECK-P9-NEXT: addis 3, 2, arr@toc@ha
113 ; CHECK-P9-NEXT: li 4, 0
114 ; CHECK-P9-NEXT: addi 3, 3, arr@toc@l
115 ; CHECK-P9-NEXT: ori 4, 4, 32768
116 ; CHECK-P9-NEXT: lfdx 0, 3, 4
117 ; CHECK-P9-NEXT: addis 3, 2, .LCPI5_0@toc@ha
118 ; CHECK-P9-NEXT: lfd 1, .LCPI5_0@toc@l(3)
119 ; CHECK-P9-NEXT: xsadddp 1, 0, 1
122 ; CHECK-P8-LABEL: doubleLargeConstantArray:
124 ; CHECK-P8-NEXT: addis 3, 2, arr@toc@ha
125 ; CHECK-P8-NEXT: li 4, 0
126 ; CHECK-P8-NEXT: addi 3, 3, arr@toc@l
127 ; CHECK-P8-NEXT: ori 4, 4, 32768
128 ; CHECK-P8-NEXT: lfdx 0, 3, 4
129 ; CHECK-P8-NEXT: addis 3, 2, .LCPI5_0@toc@ha
130 ; CHECK-P8-NEXT: lfd 1, .LCPI5_0@toc@l(3)
131 ; CHECK-P8-NEXT: xsadddp 1, 0, 1
133 %1 = load double, ptr getelementptr inbounds ([20000 x double], ptr @arr, i64 0, i64 4096), align 8
134 %2 = fadd double %1, 6.880000e+00
138 @vec_arr = global [10 x <4 x i32>] zeroinitializer, align 16
140 define <4 x i32> @vectorArray() #0 {
141 ; CHECK-P9-LABEL: vectorArray:
142 ; CHECK-P9: # %bb.0: # %entry
143 ; CHECK-P9-NEXT: addis 3, 2, .LC0@toc@ha
144 ; CHECK-P9-NEXT: ld 3, .LC0@toc@l(3)
145 ; CHECK-P9-NEXT: lxv 34, 32(3)
148 ; CHECK-P8-LABEL: vectorArray:
149 ; CHECK-P8: # %bb.0: # %entry
150 ; CHECK-P8-NEXT: addis 3, 2, .LC0@toc@ha
151 ; CHECK-P8-NEXT: ld 3, .LC0@toc@l(3)
152 ; CHECK-P8-NEXT: addi 3, 3, 32
153 ; CHECK-P8-NEXT: lxvd2x 0, 0, 3
154 ; CHECK-P8-NEXT: xxswapd 34, 0
157 %0 = load <4 x i32>, ptr getelementptr inbounds ([10 x <4 x i32>], ptr @vec_arr, i64 0, i64 2), align 16