This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Scalar vector binary operation


On Wed, 3 Nov 2010, Artem Shinkarov wrote:

> @@ -9387,6 +9387,104 @@ push_cleanup (tree decl, tree cleanup, b
>    TREE_OPERAND (stmt, 0) = list;
>    STATEMENT_LIST_STMT_EXPR (list) = stmt_expr;
>  }
> +
> +/* Return true if expression EXPR can be converted to the
> +   vectortype TYPE preserving its value.  */

"vector type" (two words)

> +static bool
> +expr_fits_type_p (tree expr, tree type)
> +{

I don't see anything here to handle removing widening conversions from 
expr.  Say you have a variable of type short - do you expect to be able to 
do a binary operation between that variable and a vector of shorts?  
Because the variable will have been converted to int.  I don't see any 
testcases in this area either.

If you do want to allow that, rather than making this function smarter and 
so making the language definition depend on how smart the compiler is 
about seeing what conversions are safe I think it might be better to avoid 
having build_binary_op calling default_conversion on the scalar operand in 
a mixed vector/scalar operation.

> +/* Convert scalar to vector for the range of operations.  
> +   Function can return:
> +        -2  --  Error ocured

"occurred"

> +        -1  --  Nothing happened
> +         0  --  First argument must be expanded
> +         1  --  Second argument must be expanded  */

Please define an enum giving symbolic names to the possible return values, 
rather than using magic constants.  */

> +              error_at (loc, "Conversion of scalar to vector "
> +                             "involves truncation");

Diagnostics should not start with capital letters.  Likewise for all the 
other diagnostics in this function.

The patch does not seem to include any testcases for bitwise operations 
(&^|).  If they are meant to work with mixed scalar/vector operations 
(which would be my expectation), then testcases are needed unless already 
in the testsuite; if not, testcases are still needed and the documentation 
needs to make clear they are not allowed.

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]