we already test for exact type matches early, so we don't have to do
it explicitly for vectors. This allows us to unnest some code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45600 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index 087fb95..6661cfb 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -1111,24 +1111,21 @@
if (LV->getElementType().getTypePtr() == rhsType.getTypePtr())
return Compatible;
}
- if (!getLangOptions().LaxVectorConversions) {
- if (lhsType != rhsType)
- return Incompatible;
- } else {
- if (lhsType->isVectorType() && rhsType->isVectorType()) {
- // If LHS and RHS are both integer or both floating point types, and
- // the total vector length is the same, allow the conversion. This is
- // a bitcast; no bits are changed but the result type is different.
- if ((lhsType->isIntegerType() && rhsType->isIntegerType()) ||
- (lhsType->isRealFloatingType() &&
- rhsType->isRealFloatingType())) {
- if (Context.getTypeSize(lhsType, SourceLocation()) ==
- Context.getTypeSize(rhsType, SourceLocation()))
- return Compatible;
- }
+
+ if (getLangOptions().LaxVectorConversions &&
+ lhsType->isVectorType() && rhsType->isVectorType()) {
+ // If LHS and RHS are both integer or both floating point types, and
+ // the total vector length is the same, allow the conversion. This is
+ // a bitcast; no bits are changed but the result type is different.
+ if ((lhsType->isIntegerType() && rhsType->isIntegerType()) ||
+ (lhsType->isRealFloatingType() &&
+ rhsType->isRealFloatingType())) {
+ if (Context.getTypeSize(lhsType, SourceLocation()) ==
+ Context.getTypeSize(rhsType, SourceLocation()))
+ return Compatible;
}
- return Incompatible;
}
+ return Incompatible;
}
return Compatible;
}