aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis
diff options
context:
space:
mode:
authorJonas Paulsson <paulsson@linux.vnet.ibm.com>2018-10-10 07:36:27 +0000
committerJonas Paulsson <paulsson@linux.vnet.ibm.com>2018-10-10 07:36:27 +0000
commit24446e792a375709a6c0f0c2555574cc946aebd0 (patch)
treecf08a50a66b6b35d3b37da8ecfc5de8d4be7b3f0 /test/Analysis
parent91f4bc63a87febf8a91d45bae9aef7dd8db13945 (diff)
[SystemZ] Take better care when computing needed vector registers in TTI.
A new function getNumVectorRegs() is better to use for the number of needed vector registers instead of getNumberOfParts(). This is to make sure that the number of vector registers (and typically operations) required for a vector type is accurate. getNumberOfParts() which was previously used works by splitting the vector type until it is legal gives incorrect results for types with a non power of two number of elements (rare). A new static function getScalarSizeInBits() that also checks for a pointer type and returns 64U for it since otherwise it gets a value of 0). Used in a few places where Ty may be pointer. Review: Ulrich Weigand git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344115 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis')
-rw-r--r--test/Analysis/CostModel/SystemZ/load-ptr-cmp-fold.ll11
-rw-r--r--test/Analysis/CostModel/SystemZ/numvectorregs.ll10
2 files changed, 21 insertions, 0 deletions
diff --git a/test/Analysis/CostModel/SystemZ/load-ptr-cmp-fold.ll b/test/Analysis/CostModel/SystemZ/load-ptr-cmp-fold.ll
new file mode 100644
index 00000000000..68227973d06
--- /dev/null
+++ b/test/Analysis/CostModel/SystemZ/load-ptr-cmp-fold.ll
@@ -0,0 +1,11 @@
+; RUN: opt < %s -cost-model -analyze -mtriple=systemz-unknown -mcpu=z13 | FileCheck %s
+
+; Test that the cost heuristic for a folded load works also for a pointer operand.
+define void @fun0(i64* %lhs, i64** %rhs_ptr) {
+ %rhs = load i64*, i64** %rhs_ptr
+ %c = icmp eq i64* %lhs, %rhs
+ ret void
+; CHECK: Printing analysis 'Cost Model Analysis' for function 'fun0':
+; CHECK: Cost Model: Found an estimated cost of 0 for instruction: %rhs = load
+; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %c = icmp
+}
diff --git a/test/Analysis/CostModel/SystemZ/numvectorregs.ll b/test/Analysis/CostModel/SystemZ/numvectorregs.ll
new file mode 100644
index 00000000000..35b58e33704
--- /dev/null
+++ b/test/Analysis/CostModel/SystemZ/numvectorregs.ll
@@ -0,0 +1,10 @@
+; RUN: opt < %s -cost-model -analyze -mtriple=systemz-unknown -mcpu=z13 | FileCheck %s
+
+; Test that the cost for the number of vector registers is returned for a
+; non-power-of-two vector type.
+define <6 x double> @fun0(<6 x double> %lhs, <6 x double> %rhs) {
+ %a = fadd <6 x double> %lhs, %rhs
+ ret <6 x double> %a
+; CHECK: Printing analysis 'Cost Model Analysis' for function 'fun0':
+; CHECK: Cost Model: Found an estimated cost of 3 for instruction: %a = fadd <6 x double>
+}