From a4e94a26baa4edfd4dc486a6ff7d26f33ff6ac21 Mon Sep 17 00:00:00 2001 From: "james.brodman" Date: Thu, 17 Jan 2013 15:45:51 -0500 Subject: [PATCH] Tweak to not oversize short vec types for 64 bit values --- expr.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/expr.cpp b/expr.cpp index 4ebd29c1..73697605 100644 --- a/expr.cpp +++ b/expr.cpp @@ -3803,6 +3803,7 @@ ExprList::GetConstant(const Type *type) const { // uniform short vector type AssertPos(pos, type->IsUniformType() && CastType(type) != NULL); + llvm::VectorType *lvt = llvm::dyn_cast(lt); AssertPos(pos, lvt != NULL); @@ -3810,8 +3811,22 @@ ExprList::GetConstant(const Type *type) const { // Uniform short vectors are stored as vectors of length // rounded up to the native vector width. So we add additional // undef values here until we get the right size. - while ((cv.size() % g->target.nativeVectorWidth) != 0) + int vectorWidth = g->target.nativeVectorWidth; + const VectorType *vt = CastType(type); + const AtomicType *bt = vt->GetElementType(); + + if (Type::Equal(bt->GetAsUniformType(), AtomicType::UniformInt64) || + Type::Equal(bt->GetAsUniformType(), AtomicType::UniformUInt64) || + Type::Equal(bt->GetAsUniformType(), AtomicType::UniformDouble)) { + // target.nativeVectorWidth should be in terms of 32-bit + // values, so for the 64-bit guys, it takes half as many of + // them to fill the native width + vectorWidth /= 2; + } + + while ((cv.size() % vectorWidth) != 0) { cv.push_back(llvm::UndefValue::get(lvt->getElementType())); + } return llvm::ConstantVector::get(cv); }