On Fri, 17 Aug 2012, Jakub Jelinek wrote:
On Fri, Aug 03, 2012 at 10:47:25PM +0200, Marc Glisse wrote:
Hello,
this is a follow up to the patch applied after this discussion:
http://gcc.gnu.org/ml/gcc-patches/2012-05/msg00504.html
It handles the -mavx __builtin_shuffle case mentioned there.
It passes bootstrap (languages=c,c++) and regtest on x86_64.
Ok. Thanks.
2012-08-04 Marc Glisse <marc.gli...@inria.fr>
gcc/
* simplify-rtx.c (simplify_binary_operation_1): Optimize shuffle of
a concatenation.
gcc/testsuite/
* gcc.target/i386/perm-concat.c: New test.
Thanks, committed.
I just noticed that for __builtin_shuffle, this is an optimization that
fold_ternary knows, but which never happens for 2 reasons:
1) the first time it sees the VEC_PERM_EXPR, the last argument is a
CONSTRUCTOR but it only handles VECTOR_CST (this also breaks constexpr
in C++11)
2) arg0 and arg1 are ssa names, not directly constructors, and there is no
combine pass.
fold_ternary does get called quite a few times on it, so I tried cheating
in gdb and replacing the ssa names by the constructors, and it did fold as
expected, but the optimization was then discarded because
valid_gimple_rhs_p doesn't like constructors.
I guess I'll have to add it to forwprop (it can make sense to restrict it
to the case where the constructor is only used once, since shuffles might
be faster than constructions).
--
Marc Glisse