From ce275675d33142c235d7027db16abe43da616ee4 Mon Sep 17 00:00:00 2001 From: Tanya Lattner Date: Mon, 28 Nov 2011 23:18:11 +0000 Subject: [PATCH] Correct the code generation for function arguments of vec3 types on x86_64 when they are greater than 128 bits. This was incorrectly coercing things like long3 into a double2. Add test case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145312 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/TargetInfo.cpp | 2 +- test/CodeGen/x86_64-arguments.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index 73bb9902cb..944eae85d5 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -1427,7 +1427,7 @@ llvm::Type *X86_64ABIInfo::GetByteVectorType(QualType Ty) const { if (llvm::VectorType *VT = dyn_cast(IRType)){ llvm::Type *EltTy = VT->getElementType(); unsigned BitWidth = VT->getBitWidth(); - if ((BitWidth == 128 || BitWidth == 256) && + if ((BitWidth >= 128 && BitWidth <= 256) && (EltTy->isFloatTy() || EltTy->isDoubleTy() || EltTy->isIntegerTy(8) || EltTy->isIntegerTy(16) || EltTy->isIntegerTy(32) || EltTy->isIntegerTy(64) || diff --git a/test/CodeGen/x86_64-arguments.c b/test/CodeGen/x86_64-arguments.c index ea7dd79c79..0536bf7702 100644 --- a/test/CodeGen/x86_64-arguments.c +++ b/test/CodeGen/x86_64-arguments.c @@ -318,3 +318,11 @@ int f44(int i, ...) { __builtin_va_end(ap); return s.y; } + +// Text that vec3 returns the correct LLVM IR type. +// CHECK: define i32 @foo(<3 x i64> %X) +typedef long long3 __attribute((ext_vector_type(3))); +int foo(long3 X) +{ + return 0; +} -- 2.40.0