cfe-dev Digest, Vol 55, Issue 35

Hi Guy,

the scalar operand should be converted to the Vector's
elements type, and the widened to a vector of the same size as the
vector operand.

There's a complication described in Section 6.2.6 (Usual Arithmetic

- "An error shall occur if any scalar operand has greater rank than the type
of the vector element."

- "2. The rank of any floating-point type is greater than the rank of any
integer type."

Therefore, expressions like "(int2)(0,1) + 1.0f" must be rejected. Our
frontend gives the following error messages on your test code: error: Cannot downconvert and widen scalar
type 'float' to vector type 'int4'
        int4 res = ivec + f;
                   ~~~~ ^ ~ error: Cannot downconvert and widen scalar
type 'float' to vector type 'int4'
        int4 res2 = f + ivec;
                    ~ ^ ~~~~

We are happy to submit soon a patch implementing this, but are about to
submit another one (and also are waiting for last submitted patch
( to be

Best wishes,

Hi Anton,
Thanks for your answer. You're right, I've missed that part in the spec.

Attached a fixed patch.


vector_scalar2.patch (5.25 KB)

Hi Guy,

Thanks for the update. Could you please provide test cases for each rule in
section 6.2.6?

Also, please follow the usual LLVM style:

   * if(..) -> if (..)

   * }else if(..) -> } else if (..)

   * terminate comments with dots, etc.


Hi Anton,
Here is the updated patch.
Added test cases for the relevant rules in section 6.2.6.

Please review.


vector_scalar3.patch (7.22 KB)