This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [rtl] combine a vec_concat of 2 vec_selects from the same vector
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: Marc Glisse <marc dot glisse at inria dot fr>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sat, 29 Sep 2012 15:07:34 +0200
- Subject: Re: [rtl] combine a vec_concat of 2 vec_selects from the same vector
- References: <alpine.DEB.2.02.1209091258520.5537@stedding.saclay.inria.fr>
> this patch lets the compiler try to rewrite:
>
> (vec_concat (vec_select x [a]) (vec_select x [b]))
>
> as:
>
> vec_select x [a b]
>
> or even just "x" if appropriate.
>
> In a first iteration I was restricting it to b-a==1, but it seemed better
> not to: it helps for {v[1],v[0]} and doesn't change anything for unknown
> patterns.
>
> Note that I am planning to do a similar optimization at tree level, but it
> shouldn't make this one useless because such patterns can be created
> during rtl passes. The testcase may need an additional -fno-tree-xxx to
> still be useful at that point though.
>
>
> bootstrap+testsuite on x86_64-linux-gnu.
>
> 2012-09-09 Marc Glisse <marc.glisse@inria.fr>
>
> gcc/
> * simplify-rtx.c (simplify_binary_operation_1): Handle vec_concat
> of vec_selects from the same vector.
* simplify-rtx.c (simplify_binary_operation_1) <VEC_CONCAT>: Handle
VEC_SELECTs from the same vector.
> gcc/testsuite/
> * gcc.target/i386/vect-rebuild.c: New testcase.
OK, but:
1) Always add a comment describing the simplification when you add one,
2) The condition:
> + if (GET_MODE (XEXP (trueop0, 0)) == mode
> + && INTVAL (XVECEXP (XEXP (trueop1, 1), 0, 0))
> + - INTVAL (XVECEXP (XEXP (trueop0, 1), 0, 0)) == 1)
> + return XEXP (trueop0, 0);
can be simplified: if GET_MODE (XEXP (trueop0, 0)) == mode, then XEXP
(trueop0, 0) is a 2-element vector so the only possible case is (0,1).
That would probably even be more correct since you don't test CONST_INT_P for
the indices, while the test is done in the VEC_SELECT case.
Why not generalizing to all kinds of VEC_SELECTs instead of just scalar ones?
--
Eric Botcazou