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: Fold vector to scalar optimization


On Mon, Nov 1, 2010 at 9:11 PM, Artem Shinkarov
<artyom.shinkaroff@gmail.com> wrote:
> This patch folds a vector of equal values to the scalar in
> vector-shift operation.
>
> ChangeLog:
>
> 2010-11-01 ?Artjoms Sinkarovs <artyom.shinakroff@gmail.com>
>
> ? ? gcc/
> ? ? * passes.c (init_optimization_passes): Move veclower after SSA.
> ? ? * tree-vect-generic.c (expand_vector_operations_1): Handle conversion.
>
> ? ? gcc/testsuite/
> ? ? * gcc.dg/vec-scal-opt.c: New testcase.
> ? ? * gcc.dg/vec-scal-opt1.c: New testcase.
> ? ? * gcc.dg/vec-scal-opt2.c: New testcase.
>
>
> bootstrapped and tested on x86_64_unknown-linux
>
> OK?

@@ -436,8 +436,72 @@ expand_vector_operations_1 (gimple_stmt_
     {
       /* If the 2nd argument is vector, we need a vector/vector shift */
       if (VECTOR_MODE_P (TYPE_MODE (TREE_TYPE (rhs2))))
-       op = optab_for_tree_code (code, type, optab_vector);
-      else
+        {
+          /* Chack whether we have vector <op> {x,x,x,x} where x

Typo.  'Check'

+             could be a scalar variable or a constant. Transform
+             vector <op> {x,x,x,x} ==> vector <op> scalar.  */
+          if (TREE_CODE (rhs2) == SSA_NAME
+              && TREE_CODE (TREE_TYPE (rhs2)) == VECTOR_TYPE)

So this misses the case when rhs2 is a VECTOR_CST.  Also in
case we have such a constant vector but then no support for
vector <<>> scalar we wil expand it again.  So I think it's better
to check the two case up-front and only rewrite the shift operand
if the scalar variant is supported.

For less gratious indents please split recognizing a vector with
all the same elements into a separate function like
bool uniform_vector_p (tree vector).

Thanks,
Richard.


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