summaryrefslogtreecommitdiff
path: root/test/CodeGen/x86-vector-width.c
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2018-10-24 17:42:17 +0000
committerCraig Topper <craig.topper@intel.com>2018-10-24 17:42:17 +0000
commitc83cf570cd01a948fc0f209616379373f83043b9 (patch)
treed9abd68ab134c5ec6dcf5f640b6ba881030bb38a /test/CodeGen/x86-vector-width.c
parent200207c0f1780bf30c7c532339507e501b8d595d (diff)
downloadclang-c83cf570cd01a948fc0f209616379373f83043b9.tar.gz
[CodeGen] Update min-legal-vector width based on function argument and return types
This is a continuation of my patches to inform the X86 backend about what the largest IR types are in the function so that we can restrict the backend type legalizer to prevent 512-bit vectors on SKX when -mprefer-vector-width=256 is specified if no explicit 512 bit vectors were specified by the user. This patch updates the vector width based on the argument and return types of the current function and from the types of any functions it calls. This is intended to make sure the backend type legalizer doesn't disturb any types that are required for ABI. Differential Revision: https://reviews.llvm.org/D52441 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345168 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/x86-vector-width.c')
-rw-r--r--test/CodeGen/x86-vector-width.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/CodeGen/x86-vector-width.c b/test/CodeGen/x86-vector-width.c
new file mode 100644
index 0000000000..7e03fedb78
--- /dev/null
+++ b/test/CodeGen/x86-vector-width.c
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -triple i686-linux-gnu -target-cpu i686 -emit-llvm %s -o - | FileCheck %s
+
+typedef signed long long V2LLi __attribute__((vector_size(16)));
+typedef signed long long V4LLi __attribute__((vector_size(32)));
+
+V2LLi ret_128();
+V4LLi ret_256();
+void arg_128(V2LLi);
+void arg_256(V4LLi);
+
+// Make sure return type forces a min-legal-width
+V2LLi foo(void) {
+ return (V2LLi){ 0, 0 };
+}
+
+V4LLi goo(void) {
+ return (V4LLi){ 0, 0 };
+}
+
+// Make sure return type of called function forces a min-legal-width
+void hoo(void) {
+ V2LLi tmp_V2LLi;
+ tmp_V2LLi = ret_128();
+}
+
+void joo(void) {
+ V4LLi tmp_V4LLi;
+ tmp_V4LLi = ret_256();
+}
+
+// Make sure arg type of called function forces a min-legal-width
+void koo(void) {
+ V2LLi tmp_V2LLi;
+ arg_128(tmp_V2LLi);
+}
+
+void loo(void) {
+ V4LLi tmp_V4LLi;
+ arg_256(tmp_V4LLi);
+}
+
+// Make sure arg type of our function forces a min-legal-width
+void moo(V2LLi x) {
+
+}
+
+void noo(V4LLi x) {
+
+}
+
+// CHECK: {{.*}}@foo{{.*}} #0
+// CHECK: {{.*}}@goo{{.*}} #1
+// CHECK: {{.*}}@hoo{{.*}} #0
+// CHECK: {{.*}}@joo{{.*}} #1
+// CHECK: {{.*}}@koo{{.*}} #0
+// CHECK: {{.*}}@loo{{.*}} #1
+// CHECK: {{.*}}@moo{{.*}} #0
+// CHECK: {{.*}}@noo{{.*}} #1
+
+// CHECK: #0 = {{.*}}"min-legal-vector-width"="128"
+// CHECK: #1 = {{.*}}"min-legal-vector-width"="256"