[cfe-dev] [OpenCL patch] Vector logical operations

Eli Friedman eli.friedman at gmail.com
Fri Jan 13 21:10:45 PST 2012


On Fri, Jan 13, 2012 at 8:22 PM, Tanya Lattner <lattner at apple.com> wrote:
>
> On Jan 12, 2012, at 12:33 PM, Eli Friedman wrote:
>
>> On Thu, Jan 12, 2012 at 3:04 AM, Anton Lokhmotov
>> <Anton.Lokhmotov at arm.com> wrote:
>>> 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.

-Eli




More information about the cfe-dev mailing list