This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fold vector to scalar optimization
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Artem Shinkarov <artyom dot shinkaroff at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Tue, 2 Nov 2010 12:03:46 +0100
- Subject: Re: Fold vector to scalar optimization
- References: <AANLkTi=3da3vdjgDQNF1d3ZaVr_Ek27qwvEVimoramQQ@mail.gmail.com>
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.