aboutsummaryrefslogtreecommitdiff
path: root/CodeGen/CGExpr.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-08-03 15:52:31 +0000
committerChris Lattner <sabre@nondot.org>2007-08-03 15:52:31 +0000
commit3b126125ec5dc9f17cf94e2b11acde0edce9dd6a (patch)
tree5d9d22374dd4758c6a1f1f363459d40e410b52e8 /CodeGen/CGExpr.cpp
parent46ea8eb7cc6244b479e6feca55cf234a91d383d7 (diff)
Add support for scalar-returning element accesses like V.x
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40777 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CodeGen/CGExpr.cpp')
-rw-r--r--CodeGen/CGExpr.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/CodeGen/CGExpr.cpp b/CodeGen/CGExpr.cpp
index 7d8dc8c33b..178107e2ee 100644
--- a/CodeGen/CGExpr.cpp
+++ b/CodeGen/CGExpr.cpp
@@ -287,13 +287,23 @@ RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, QualType ExprType) {
// shuffle the input or extract/insert them as appropriate.
if (LV.isOCUVectorComp()) {
llvm::Value *Vec = Builder.CreateLoad(LV.getOCUVectorAddr(), "tmp");
+
+ unsigned EncFields = LV.getOCUVectorComp();
+
+ // If the result of the expression is a non-vector type, we must be
+ // extracting a single element. Just codegen as an extractelement.
+ if (!isa<VectorType>(ExprType)) {
+ unsigned InIdx = OCUVectorComponent::getAccessedFieldNo(0, EncFields);
+ llvm::Value *Elt = llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx);
+ return RValue::get(Builder.CreateExtractElement(Vec, Elt, "tmp"));
+ }
+
+
unsigned NumElts = cast<VectorType>(ExprType)->getNumElements();
// Start out with an undef of the result type.
llvm::Value *Result = llvm::UndefValue::get(ConvertType(ExprType));
- unsigned EncFields = LV.getOCUVectorComp();
-
// Extract/Insert each element of the result.
for (unsigned i = 0; i != NumElts; ++i) {
unsigned InIdx = OCUVectorComponent::getAccessedFieldNo(i, EncFields);