summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/PowerPC
diff options
context:
space:
mode:
authorQingShan Zhang <qshanz@cn.ibm.com>2018-06-19 06:54:51 +0000
committerQingShan Zhang <qshanz@cn.ibm.com>2018-06-19 06:54:51 +0000
commit9f0fe9a3f86d4c3afd7dc765a28eadf6ae522135 (patch)
treeec30d1bb2da1f0dc42c3de3806585d2b5c83414d /llvm/test/CodeGen/PowerPC
parentec03fbe8bbc4f00bd71d45cf617f9412ef984ada (diff)
downloadbcm5719-llvm-9f0fe9a3f86d4c3afd7dc765a28eadf6ae522135.tar.gz
bcm5719-llvm-9f0fe9a3f86d4c3afd7dc765a28eadf6ae522135.zip
If the arch is P9, we will select the DFLOADf32/DFLOADf64 pseudo instruction when we are loading a floating,
and expand it post RA basing on the register pressure. However, we miss to do the add-imm peephole for these pseudo instruction. Differential Revision: https://reviews.llvm.org/D47568 Reviewed By: Nemanjai llvm-svn: 335024
Diffstat (limited to 'llvm/test/CodeGen/PowerPC')
-rw-r--r--llvm/test/CodeGen/PowerPC/mcm-12.ll3
-rw-r--r--llvm/test/CodeGen/PowerPC/toc-float.ll71
2 files changed, 72 insertions, 2 deletions
diff --git a/llvm/test/CodeGen/PowerPC/mcm-12.ll b/llvm/test/CodeGen/PowerPC/mcm-12.ll
index f6b54c3ba9a..8ba8a38a4df 100644
--- a/llvm/test/CodeGen/PowerPC/mcm-12.ll
+++ b/llvm/test/CodeGen/PowerPC/mcm-12.ll
@@ -33,5 +33,4 @@ entry:
; CHECK-P9: .quad 4562098671269285104
; CHECK-P9-LABEL: test_double_const:
; CHECK-P9: addis [[REG1:[0-9]+]], 2, [[VAR]]@toc@ha
-; CHECK-P9: addi [[REG1]], {{[0-9]+}}, [[VAR]]@toc@l
-; CHECK-P9: lfd {{[0-9]+}}, 0([[REG1]])
+; CHECK-P9: lfd {{[0-9]+}}, [[VAR]]@toc@l([[REG1]])
diff --git a/llvm/test/CodeGen/PowerPC/toc-float.ll b/llvm/test/CodeGen/PowerPC/toc-float.ll
new file mode 100644
index 00000000000..814e069bc08
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/toc-float.ll
@@ -0,0 +1,71 @@
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr9 <%s | FileCheck %s
+
+; As the constant could be represented as float, a float is
+; loaded from constant pool.
+define double @doubleConstant1() {
+ ret double 1.400000e+01
+}
+
+; CHECK-LABEL: doubleConstant1:
+; CHECK: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha
+; CHECK: lfs {{[0-9]+}}, [[VAR]]@toc@l([[REG1]])
+
+; As the constant couldn't be represented as float, a double is
+; loaded from constant pool.
+define double @doubleConstant2() {
+ ret double 2.408904e+01
+}
+
+; CHECK-LABEL: doubleConstant2:
+; CHECK: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha
+; CHECK: lfd {{[0-9]+}}, [[VAR]]@toc@l([[REG1]])
+
+@FArr = hidden local_unnamed_addr global [10 x float] zeroinitializer, align 4
+
+define float @floatConstantArray() local_unnamed_addr {
+ %1 = load float, float* getelementptr inbounds ([10 x float], [10 x float]* @FArr, i64 0, i64 3), align 4
+ %2 = fadd float %1, 0x400B333340000000
+ ret float %2
+}
+
+; CHECK-LABEL: floatConstantArray
+; CHECK: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha+[[REG2:[0-9]+]]
+; CHECK: lfs {{[0-9]+}}, [[VAR]]@toc@l+[[REG2]]([[REG1]])
+
+define float @floatConstant() {
+ ret float 0x400470A3E0000000
+}
+
+; CHECK-LABEL: floatConstant:
+; CHECK: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha
+; CHECK: lfs {{[0-9]+}}, [[VAR]]@toc@l([[REG1]])
+
+; llvm put the hidden globals into the TOC table.
+; TODO - do some analysis and decide which globals could be put into TOC.
+@d = hidden local_unnamed_addr global [200 x double] zeroinitializer, align 8
+
+define double @doubleConstantArray() {
+ %1 = load double, double* getelementptr inbounds ([200 x double], [200 x double]* @d, i64 0, i64 3), align 8
+ %2 = fadd double %1, 6.880000e+00
+ ret double %2
+}
+
+; CHECK-LABEL: doubleConstantArray
+; CHECK: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha+[[REG2:[0-9]+]]
+; CHECK: lfd {{[0-9]+}}, [[VAR]]@toc@l+[[REG2]]([[REG1]])
+
+@arr = hidden local_unnamed_addr global [20000 x double] zeroinitializer, align 8
+
+define double @doubleLargeConstantArray() {
+ %1 = load double, double* getelementptr inbounds ([20000 x double], [20000 x double]* @arr, i64 0, i64 4096), align 8
+ %2 = fadd double %1, 6.880000e+00
+ ret double %2
+}
+
+; access element that out of range
+; CHECK-LABEL: doubleLargeConstantArray
+; CHECK: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha
+; CHECK: li [[REG2:[0-9]+]], 0
+; CHECK: addi [[REG3:[0-9]+]], [[REG1]], [[VAR:[a-z0-9A-Z_.]+]]@toc@l
+; CHECK: ori [[REG4:[0-9]+]], [[REG2]], 32768
+; CHECK: lfdx {{[0-9]+}}, [[REG3]], [[REG4]]
OpenPOWER on IntegriCloud