On Thu, 3 Jan 2019, Jakub Jelinek wrote:

The following patch adds support for the __builtin_convertvector builtin.
C casts on generic vectors are just reinterpretation of the bits (i.e. a
VCE), this builtin allows to cast int/unsigned elements to float or vice
versa or promote/demote them.  doc/ change is missing, will write it soon.

The builtin appeared in I think clang 3.4 and is apparently in real-world
use as e.g. Honza reported.  The first argument is an expression with vector
type, the second argument is a vector type (similarly e.g. to va_arg), to
which the first argument should be converted.  Both vector types need to
have the same number of elements.

I've implemented same element size (thus also whole vector size) conversions
efficiently - signed to unsigned and vice versa or same vector type just
using a VCE, for e.g. int <-> float or long long <-> double using
appropriate optab, possibly repeated multiple times for very large vectors.

Hello,

IIUC, you only lower __builtin_convertvector to VCE or FLOAT_EXPR or whatever in tree-vect-generic. That seems quite late. At least for the "easy" same-size case, I think we should do it early (gimplification?), before we start optimizing, without checking if it is supported by the target (generic lowering can fix that up later). Of course that can be changed later, getting the basic functionality comes first.

(while you are writing the doc patch: tree.def and generic.texi do not say anything about using FLOAT_EXPR on a vector)

--
Marc Glisse

Reply via email to