1 ; RUN: llc -relocation-model=pic -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr9 <%s | FileCheck -check-prefix=CHECK-P9 %s
2 ; RUN: llc -relocation-model=pic -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 <%s | FileCheck -check-prefix=CHECK-P8 %s
4 ; As the constant could be represented as float, a float is
5 ; loaded from constant pool.
6 define double @doubleConstant1() {
7 ret double 1.400000e+01
9 ; CHECK-P9-LABEL: doubleConstant1:
10 ; CHECK-P9: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha
11 ; CHECK-P9: lfs {{[0-9]+}}, [[VAR]]@toc@l([[REG1]])
12 ; CHECK-P8-LABEL: doubleConstant1:
13 ; CHECK-P8: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha
14 ; CHECK-P8: lfs {{[0-9]+}}, [[VAR]]@toc@l([[REG1]])
17 ; As the constant couldn't be represented as float, a double is
18 ; loaded from constant pool.
19 define double @doubleConstant2() {
20 ret double 2.408904e+01
22 ; CHECK-P9-LABEL: doubleConstant2:
23 ; CHECK-P9: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha
24 ; CHECK-P9: lfd {{[0-9]+}}, [[VAR]]@toc@l([[REG1]])
25 ; CHECK-P8-LABEL: doubleConstant2:
26 ; CHECK-P8: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha
27 ; CHECK-P8: lfd {{[0-9]+}}, [[VAR]]@toc@l([[REG1]])
30 @FArr = hidden local_unnamed_addr global [10 x float] zeroinitializer, align 4
32 define float @floatConstantArray() local_unnamed_addr {
33 %1 = load float, float* getelementptr inbounds ([10 x float], [10 x float]* @FArr, i64 0, i64 3), align 4
34 %2 = fadd float %1, 0x400B333340000000
37 ; CHECK-P9-LABEL: floatConstantArray
38 ; CHECK-P9: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha+[[REG2:[0-9]+]]
39 ; CHECK-P9: lfs {{[0-9]+}}, [[VAR]]@toc@l+[[REG2]]([[REG1]])
40 ; CHECK-P8-LABEL: floatConstantArray
41 ; CHECK-P8: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha
42 ; CHECK-P8: addi [[REG2:[0-9]+]], [[REG1]], [[VAR]]@toc@l
43 ; CHECK-P8: lfs {{[0-9]+}}, 12([[REG2]])
46 define float @floatConstant() {
47 ret float 0x400470A3E0000000
49 ; CHECK-P9-LABEL: floatConstant:
50 ; CHECK-P9: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha
51 ; CHECK-P9: lfs {{[0-9]+}}, [[VAR]]@toc@l([[REG1]])
52 ; CHECK-P8-LABEL: floatConstant:
53 ; CHECK-P8: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha
54 ; CHECK-P8: lfs {{[0-9]+}}, [[VAR]]@toc@l([[REG1]])
57 ; llvm put the hidden globals into the TOC table.
58 ; TODO - do some analysis and decide which globals could be put into TOC.
59 @d = hidden local_unnamed_addr global [200 x double] zeroinitializer, align 8
61 define double @doubleConstantArray() {
62 %1 = load double, double* getelementptr inbounds ([200 x double], [200 x double]* @d, i64 0, i64 3), align 8
63 %2 = fadd double %1, 6.880000e+00
66 ; CHECK-P9-LABEL: doubleConstantArray
67 ; CHECK-P9: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha+[[REG2:[0-9]+]]
68 ; CHECK-P9: lfd {{[0-9]+}}, [[VAR]]@toc@l+[[REG2]]([[REG1]])
69 ; CHECK-P8-LABEL: doubleConstantArray
70 ; CHECK-P8: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha
71 ; CHECK-P8: addi [[REG2:[0-9]+]], [[REG1]], [[VAR]]@toc@l
72 ; CHECK-P8: lfd {{[0-9]+}}, 24([[REG2]])
75 @arr = hidden local_unnamed_addr global [20000 x double] zeroinitializer, align 8
77 define double @doubleLargeConstantArray() {
78 %1 = load double, double* getelementptr inbounds ([20000 x double], [20000 x double]* @arr, i64 0, i64 4096), align 8
79 %2 = fadd double %1, 6.880000e+00
82 ; Access an element with an offset that doesn't fit in the displacement field of LFD.
83 ; CHECK-P9-LABEL: doubleLargeConstantArray
84 ; CHECK-P9: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha
85 ; CHECK-P9: li [[REG2:[0-9]+]], 0
86 ; CHECK-P9: addi [[REG3:[0-9]+]], [[REG1]], [[VAR:[a-z0-9A-Z_.]+]]@toc@l
87 ; CHECK-P9: ori [[REG4:[0-9]+]], [[REG2]], 32768
88 ; CHECK-P9: lfdx {{[0-9]+}}, [[REG3]], [[REG4]]
89 ; CHECK-P8-LABEL: doubleLargeConstantArray
90 ; CHECK-P8: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha
91 ; CHECK-P8: li [[REG2:[0-9]+]], 0
92 ; CHECK-P8: addi [[REG3:[0-9]+]], [[REG1]], [[VAR:[a-z0-9A-Z_.]+]]@toc@l
93 ; CHECK-P8: ori [[REG4:[0-9]+]], [[REG2]], 32768
94 ; CHECK-P8: lfdx {{[0-9]+}}, [[REG3]], [[REG4]]
97 @vec_arr = global [10 x <4 x i32>] zeroinitializer, align 16
99 define <4 x i32> @vectorArray() #0 {
101 %0 = load <4 x i32>, <4 x i32>* getelementptr inbounds ([10 x <4 x i32>], [10 x <4 x i32>]* @vec_arr, i64 0, i64 2), align 16
104 ; CHECK-P9-LABEL: vectorArray
105 ; CHECK-P9: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha
106 ; CHECK-P9: ld [[REG2:[0-9]+]], [[VAR]]@toc@l([[REG1]])
107 ; CHECK-P9: lxv {{[0-9]+}}, 32([[REG2]])
108 ; CHECK-P8-LABEL: vectorArray
109 ; CHECK-P8: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha
110 ; CHECK-P8: ld [[REG2:[0-9]+]], [[VAR]]@toc@l([[REG1]])
111 ; CHECK-P8: addi [[REG3:[0-9]+]], [[REG2]], 32
112 ; CHECK-P8: lvx {{[0-9]+}}, 0, [[REG3]]