fix a codegen bug handling ocuvector element exprs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40995 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CodeGen/CGExpr.cpp b/CodeGen/CGExpr.cpp
index 08bd93f..8937eaf 100644
--- a/CodeGen/CGExpr.cpp
+++ b/CodeGen/CGExpr.cpp
@@ -296,14 +296,15 @@
// If this is a reference to a subset of the elements of a vector, either
// shuffle the input or extract/insert them as appropriate.
RValue CodeGenFunction::EmitLoadOfOCUElementLValue(LValue LV,
- QualType ExprType) {
+ QualType ExprType) {
llvm::Value *Vec = Builder.CreateLoad(LV.getOCUVectorAddr(), "tmp");
unsigned EncFields = LV.getOCUVectorElts();
// 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)) {
+ const VectorType *ExprVT = ExprType->getAsVectorType();
+ if (!ExprVT) {
unsigned InIdx = OCUVectorElementExpr::getAccessedFieldNo(0, EncFields);
llvm::Value *Elt = llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx);
return RValue::get(Builder.CreateExtractElement(Vec, Elt, "tmp"));
@@ -311,7 +312,7 @@
// If the source and destination have the same number of elements, use a
// vector shuffle instead of insert/extracts.
- unsigned NumResultElts = cast<VectorType>(ExprType)->getNumElements();
+ unsigned NumResultElts = ExprVT->getNumElements();
unsigned NumSourceElts =
cast<llvm::VectorType>(Vec->getType())->getNumElements();