[PATCH] Add VEC_COND_EXPR node

Devang Patel dpatel@apple.com
Wed Sep 22 19:32:00 GMT 2004


On Sep 21, 2004, at 7:17 PM, Roger Sayle wrote:

>
> On Tue, 21 Sep 2004, Richard Henderson wrote:
>> On Thu, Sep 16, 2004 at 09:47:49AM -0700, Devang Patel wrote:
>>> + DEFTREECODE (VEC_COND_EXPR, "cond_expr", 'e', 3)
>>                                  ^^^
>>                                  typo.
>>
>> Otherwise ok.
>
> Hi Devang,
>
> Would it possible to add some documentation for vec_cond_expr to
> c-tree.texi?

OK

> I'm a bit concerned about the change of sematics for
> the Boolean expressions that serve as the initial operand of ?:.
> For example, previously Boolean expression always returned a
> scalar Boolean value but in the new scheme they return the equivalent
> of a vector of Bool.
>
> Hence if A = VEC_COND_EXPR ( X < Y, B, C )
>
> means  for(i=0; i<N; i++) A[i] = X[i] < Y[i] ? B[i] : C[i];
>
> then we'll run into problems with EQ_EXPR and NE_EXPR when X and Y
> are vector constants.  Equality and inequality is already defined
> for vectors, even though the other relational operators aren't.
>
>   A = VEC_COND_EXPR (X == Y, B, C)
>
> probably intends to mean:
>
>   for(i=0; i<N; i++) A[i] = X[i] == Y[i] ? B[i] : C[i];
>
> but if tree-ssa propagates VECTOR_CSTS into the equality expression,
> we may constant fold the equality operator to false, based upon whether
> any of the elements of VECTOR_CST X differs from VECTOR_CST Y.
>
>   A = VEC_COND_EXPR (false, B, C)
>
> which ultimately, one would hope would be folded to A = C.

We need to make result of eqality expression, a vector boolean with N
elements.

> My apologies if these issues were considered and resolved when this
> topic was discussed on the gcc list, but unfortunately keeping up
> with gcc-patches is hard enough.  Has anyone considered VEC_LT_EXPR,
> VEC_GE_EXPR, VEC_EQ_EXPR, etc...?

We decided not to make vector comparison independent of VEC_COND_EXPR.



More information about the Gcc-patches mailing list