summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-07-29 05:02:29 +0000
committerChris Lattner <sabre@nondot.org>2010-07-29 05:02:29 +0000
commit9fa15c3608ee7e0277f61b296799a69a400a65ed (patch)
tree7c8610abfc3584fc97c78bf97c897604813d243f /clang/lib/CodeGen
parent4200fe4e50ad6e0f3e63764470fb85adadf9fd8d (diff)
downloadbcm5719-llvm-9fa15c3608ee7e0277f61b296799a69a400a65ed.tar.gz
bcm5719-llvm-9fa15c3608ee7e0277f61b296799a69a400a65ed.zip
ignore structs that wrap vectors in IR, the abstraction shouldn't add penalty.
Before we'd compile the example into something like: %coerce.dive2 = getelementptr %struct.v4f32wrapper* %retval, i32 0, i32 0 ; <<4 x float>*> [#uses=1] %1 = bitcast <4 x float>* %coerce.dive2 to <2 x double>* ; <<2 x double>*> [#uses=1] %2 = load <2 x double>* %1, align 1 ; <<2 x double>> [#uses=1] ret <2 x double> %2 Now we produce: %coerce.dive2 = getelementptr %struct.v4f32wrapper* %retval, i32 0, i32 0 ; <<4 x float>*> [#uses=1] %0 = load <4 x float>* %coerce.dive2, align 1 ; <<4 x float>> [#uses=1] ret <4 x float> %0 llvm-svn: 109732
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/TargetInfo.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 7321ba148ca..e8e4c5c4622 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -1185,9 +1185,20 @@ ABIArgInfo X86_64ABIInfo::getIndirectResult(QualType Ty) const {
/// full vector XMM register. Pick an LLVM IR type that will be passed as a
/// vector register.
const llvm::Type *X86_64ABIInfo::Get16ByteVectorType(QualType Ty) const {
+ const llvm::Type *IRType = CGT.ConvertTypeRecursive(Ty);
+
+ // Wrapper structs that just contain vectors are passed just like vectors,
+ // strip them off if present.
+ const llvm::StructType *STy = dyn_cast<llvm::StructType>(IRType);
+ while (STy && STy->getNumElements() == 1) {
+ IRType = STy->getElementType(0);
+ STy = dyn_cast<llvm::StructType>(IRType);
+ }
+
+
+
// If the preferred type is a 16-byte vector, prefer to pass it.
- if (const llvm::VectorType *VT =
- dyn_cast<llvm::VectorType>(CGT.ConvertTypeRecursive(Ty))){
+ if (const llvm::VectorType *VT = dyn_cast<llvm::VectorType>(IRType)){
const llvm::Type *EltTy = VT->getElementType();
if (VT->getBitWidth() == 128 &&
(EltTy->isFloatTy() || EltTy->isDoubleTy() ||
OpenPOWER on IntegriCloud