[OpenCL patch] Vector logical operations

+inline QualType Sema::CheckVectorLogicalOperands(ExprResult LHS,
ExprResult RHS,

There's no point to marking this inline.

+ } else if (const ExtVectorType *EVT = resultType->getAs<ExtVectorType>()) {
+ // Handle vector types.
+ // Vector logical not returns the signed variant of the operand type.
+ QualType EltTy = EVT->getElementType();
+ EltTy = EltTy->getAs<BuiltinType>()->getSignedVariant(EltTy, Context);
+ resultType = Context.getExtVectorType(EltTy, EVT->getNumElements());
+ break;

What if EVT is a float4?

More generally, we already have code to compute the correct result
type for both of these operations in Sema::CheckVectorCompareOperands;
please refactor the patch to use it.

-Eli

Please review a patch implementing support for vector logical operations in
OpenCL. It's based on Tanya's patch [1], with Peter's suggestions [2]
applied.

Many thanks,
Anton.

+inline QualType Sema::CheckVectorLogicalOperands(ExprResult LHS,
ExprResult RHS,

There's no point to marking this inline.

+ } else if (const ExtVectorType *EVT = resultType->getAs<ExtVectorType>()) {
+ // Handle vector types.
+ // Vector logical not returns the signed variant of the operand type.
+ QualType EltTy = EVT->getElementType();
+ EltTy = EltTy->getAs<BuiltinType>()->getSignedVariant(EltTy, Context);
+ resultType = Context.getExtVectorType(EltTy, EVT->getNumElements());
+ break;

What if EVT is a float4?

Yes, this patch is old and doesn't handle this case (or double). I'll correct it with the changes I have in my tree.

More generally, we already have code to compute the correct result
type for both of these operations in Sema::CheckVectorCompareOperands;
please refactor the patch to use it.

Ok, it may be possible to use CheckVectorCompareOperands(), but float/double will have to be a special case probably before its called.

Thanks,
Tanya

By "it", I was referring to the type-computation code in
Sema::CheckVectorCompareOperands; refactoring that code out would also
be okay.

-Eli

Yeah, I got it after looking at it closer. How about this patch?

vectorLogicalOps.patch (8.61 KB)

Taking a look at the OpenCL spec, it looks like float4 && float4 is
allowed. Is there some reason your patch doesn't allow it?

Otherwise, looks fine.

-Eli

Please review a patch implementing support for vector logical operations in
OpenCL. It's based on Tanya's patch [1], with Peter's suggestions [2]
applied.

Many thanks,
Anton.

+inline QualType Sema::CheckVectorLogicalOperands(ExprResult LHS,
ExprResult RHS,

There's no point to marking this inline.

+ } else if (const ExtVectorType *EVT = resultType->getAs<ExtVectorType>()) {
+ // Handle vector types.
+ // Vector logical not returns the signed variant of the operand type.
+ QualType EltTy = EVT->getElementType();
+ EltTy = EltTy->getAs<BuiltinType>()->getSignedVariant(EltTy, Context);
+ resultType = Context.getExtVectorType(EltTy, EVT->getNumElements());
+ break;

What if EVT is a float4?

Yes, this patch is old and doesn't handle this case (or double). I'll correct it with the changes I have in my tree.

More generally, we already have code to compute the correct result
type for both of these operations in Sema::CheckVectorCompareOperands;
please refactor the patch to use it.

Ok, it may be possible to use CheckVectorCompareOperands(), but float/double will have to be a special case probably before its called.

By "it", I was referring to the type-computation code in
Sema::CheckVectorCompareOperands; refactoring that code out would also
be okay.

Yeah, I got it after looking at it closer. How about this patch?

I think thats factored better.

Taking a look at the OpenCL spec, it looks like float4 && float4 is
allowed. Is there some reason your patch doesn't allow it?

My patch only supports OpenCL 1.1.

Thanks,
Tanya