This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: recent troubles with float vectors & bitwise ops
- From: Joe Buck <Joe dot Buck at synopsys dot COM>
- To: Ross Ridge <rridge at csclub dot uwaterloo dot ca>
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 24 Aug 2007 11:48:28 -0700
- Subject: Re: recent troubles with float vectors & bitwise ops
- References: <20070824183427.E456D74931@caffeine.csclub.uwaterloo.ca>
On Fri, Aug 24, 2007 at 02:34:27PM -0400, Ross Ridge wrote:
> Mark Mitchell
> >Let's assume that the recent change is what we want, i.e., that the
> >answer to (1) is "No, these operations should not be part of the vector
> >extensions because they are not valid scalar extensions."
>
> I don't think we should assume that. If we were to we'd also have
> to change vector casts to work like scalar casts and actually convert
> the values. (Or like valarray, disallow them completely.) That would
> force a solution like Paolo Bonzini's to use unions instead of casts,
> making it even more cumbersome.
In C++, you could use reinterpret_cast (meaning that
values are not converted, just reinterpreted as integers of the same
size). That would avoid the need for unions, you'd just cast. But this
solution doesn't work for C.
> Using vector casts that behave differently than
> scalar casts has a lot more potential to generate confusion than allowing
> bitwise operations on vector floats does.
I suppose you could have an appropriately named intrinsic for doing
a reinterpret_cast in C (that is, the type would be reinterpreted but it would
be a no-op at machine level). Then, to do a masking operation you could
write
ovec = __as_float_vector(MASK | __as_int_vector(ivec));