Patch attached. Changed checks on conditional operator to check for
ExtVectorType instead of OpenCL && VectorType in Sema/SemaExpr.cpp,
and added test cases to Sema/vector-ops.c. Feedback would be
appreciated.
Regards,
--John
Index: test/Sema/vector-ops.c
===================================================================
--- test/Sema/vector-ops.c (revision 179764)
+++ test/Sema/vector-ops.c (working copy)
@@ -26,4 +26,13 @@
v2s *v2s_ptr;
v2s_ptr = v2u_ptr; // expected-warning{{converts between pointers to integer types with different sign}}
}
+
+typedef __attribute__ ((ext_vector_type(4))) int int4;
+
+void test2(int4 vec4a, int4 vec4b) {
+ int4 vector_select_component = vec4a ? vec4a : vec4b;
+ int4 vector_select_whole = 1 ? vec4a : vec4b;
+ int4 vector_scalar = vec4a ? 1 : vec4b;
+ int4 scalar_vector = vec4a ? vec4a : 1;
+}
Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp (revision 179764)
+++ lib/Sema/SemaExpr.cpp (working copy)
@@ -4985,7 +4985,7 @@
if (CondTy->isScalarType()) return false;
// OpenCL v1.1 s6.3.i says the condition is allowed to be a vector or scalar.
- if (S.getLangOpts().OpenCL && CondTy->isVectorType())
+ if (CondTy->isExtVectorType())
return false;
// Emit the proper error message.
@@ -5248,7 +5248,7 @@
// If the condition is a vector, and both operands are scalar,
// attempt to implicity convert them to the vector type to act like the
// built in select. (OpenCL v1.1 s6.3.i)
- if (getLangOpts().OpenCL && CondTy->isVectorType())
+ if (CondTy->isExtVectorType())
if (checkConditionalConvertScalarsToVectors(*this, LHS, RHS, CondTy))
return QualType();
Index: lib/CodeGen/CGExprScalar.cpp
===================================================================
--- lib/CodeGen/CGExprScalar.cpp (revision 179764)
+++ lib/CodeGen/CGExprScalar.cpp (working copy)
@@ -3019,8 +3019,7 @@
// OpenCL: If the condition is a vector, we can treat this condition like
// the select function.
- if (CGF.getLangOpts().OpenCL
- && condExpr->getType()->isVectorType()) {
+ if (condExpr->getType()->isExtVectorType()) {
llvm::Value *CondV = CGF.EmitScalarExpr(condExpr);
llvm::Value *LHS = Visit(lhsExpr);
llvm::Value *RHS = Visit(rhsExpr);
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits