r198856 - In areVectorOperandsLaxBitCastable() allow bitcast between a vector and scalar.
Argyrios Kyrtzidis
akyrtzi at gmail.com
Wed Jan 8 23:58:22 PST 2014
Author: akirtzidis
Date: Thu Jan 9 01:58:22 2014
New Revision: 198856
URL: http://llvm.org/viewvc/llvm-project?rev=198856&view=rev
Log:
In areVectorOperandsLaxBitCastable() allow bitcast between a vector and scalar.
rdar://15779837.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/vector-cast.c
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=198856&r1=198855&r2=198856&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Jan 9 01:58:22 2014
@@ -6617,7 +6617,8 @@ static bool areVectorOperandsLaxBitCasta
if (!Ctx.getLangOpts().LaxVectorConversions)
return false;
- if (!LHSType->isVectorType() || !RHSType->isVectorType())
+ if (!(LHSType->isVectorType() || LHSType->isScalarType()) ||
+ !(RHSType->isVectorType() || RHSType->isScalarType()))
return false;
unsigned LHSSize = Ctx.getTypeSize(LHSType);
@@ -6631,13 +6632,20 @@ static bool areVectorOperandsLaxBitCasta
// Make sure such width is the same between the types, otherwise we may end
// up with an invalid bitcast.
unsigned LHSIRSize, RHSIRSize;
- const VectorType *LVec = LHSType->getAs<VectorType>();
- LHSIRSize = LVec->getNumElements() *
- Ctx.getTypeSize(LVec->getElementType());
- const VectorType *RVec = RHSType->getAs<VectorType>();
- RHSIRSize = RVec->getNumElements() *
- Ctx.getTypeSize(RVec->getElementType());
-
+ if (LHSType->isVectorType()) {
+ const VectorType *Vec = LHSType->getAs<VectorType>();
+ LHSIRSize = Vec->getNumElements() *
+ Ctx.getTypeSize(Vec->getElementType());
+ } else {
+ LHSIRSize = LHSSize;
+ }
+ if (RHSType->isVectorType()) {
+ const VectorType *Vec = RHSType->getAs<VectorType>();
+ RHSIRSize = Vec->getNumElements() *
+ Ctx.getTypeSize(Vec->getElementType());
+ } else {
+ RHSIRSize = RHSSize;
+ }
if (LHSIRSize != RHSIRSize)
return false;
Modified: cfe/trunk/test/Sema/vector-cast.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vector-cast.c?rev=198856&r1=198855&r2=198856&view=diff
==============================================================================
--- cfe/trunk/test/Sema/vector-cast.c (original)
+++ cfe/trunk/test/Sema/vector-cast.c Thu Jan 9 01:58:22 2014
@@ -36,3 +36,11 @@ void f3(t3 Y) {
f2(Y); // expected-warning {{incompatible vector types passing 't3' to parameter of type 't2'}}
}
+typedef float float2 __attribute__ ((vector_size (8)));
+
+void f4() {
+ float2 f2;
+ double d;
+ f2 += d;
+ d += f2;
+}
More information about the cfe-commits
mailing list