[cfe-commits] r128381 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp lib/Sema/SemaExpr.cpp test/Sema/vector-ops.c

John McCall rjmccall at apple.com
Mon Mar 28 00:25:01 PDT 2011


> +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Sun Mar 27 10:36:07 2011
> @@ -2119,7 +2119,9 @@
> 
>     // If AltiVec, the comparison results in a numeric type, so we use
>     // intrinsics comparing vectors and giving 0 or 1 as a result
> -    if (LHSTy->isVectorType() && CGF.getContext().getLangOptions().AltiVec) {
> +    if (LHSTy->isVectorType() &&
> +        LHSTy->getAs<VectorType>()->getVectorKind() ==
> +          VectorType::AltiVecVector) {

Instead of repeating the logic from Sema here, please just check the result
type of the expression.  If it's not a vector, we need to use one of these
intrinsics.

> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun Mar 27 10:36:07 2011
> @@ -7277,14 +7277,16 @@
>   if (vType.isNull())
>     return vType;
> 
> +  QualType lType = lex->getType();
> +  QualType rType = rex->getType();
> +
>   // If AltiVec, the comparison results in a numeric type, i.e.
>   // bool for C++, int for C
> -  if (getLangOptions().AltiVec)
> +  if (lType->getAs<VectorType>()->getVectorKind() == VectorType::AltiVecVector
> +      && rType->getAs<VectorType>()->getVectorKind() ==
> +         VectorType::AltiVecVector)
>     return Context.getLogicalOperationType();

Can't you do this by checking whether vType is an AltiVec vector type,
rather than whether the two operands were both AltiVec vectors?

John.



More information about the cfe-commits mailing list