]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/vec-perm-indices.cc
forwprop: Enhance vec perm fed by CTOR and CTOR/CST [PR99398]
authorKewen Lin <linkw@linux.ibm.com>
Fri, 28 May 2021 06:11:45 +0000 (01:11 -0500)
committerKewen Lin <linkw@linux.ibm.com>
Fri, 28 May 2021 06:11:45 +0000 (01:11 -0500)
commit4a9f2306cb39a3cf265eeb6f8f3a8bbaf230c4c8
treec37b0fcc9092378d662e6de5c0445ae8a9d8c617
parentcd62d089f6021fd1ad4537b8182836d15b14514f
forwprop: Enhance vec perm fed by CTOR and CTOR/CST [PR99398]

VEC_PERM_EXPR requires the number of MASK elements must be the
same with the number of elements in operands V0 and V1.  In
some cases, like with Power altivec built-in function vec_perm,
VIEW_CONVERT_EXPR has to be used to guarantee this requirement,
but it can prevent some simplifications which don't consider
this well.

For the cases that the permutated operands of vector
permutation are from two same type CTOR and CTOR, or one CTOR
and one VECTOR CST, this patch is to enhance forwprop to look
through intermediate VIEW_CONVERT_EXPR and further simplify
them if possible.

Bootstrapped/regtested on powerpc64le-linux-gnu P9,
powerpc64-linux-gnu P8, x86_64-redhat-linux and
aarch64-linux-gnu.

gcc/ChangeLog:

PR tree-optimization/99398
* tree-ssa-forwprop.c (simplify_permutation): Optimize some cases
where the fed operands are CTOR/CST and propagated through
VIEW_CONVERT_EXPR.  Call vec_perm_indices::new_shrunk_vector.
* vec-perm-indices.c (vec_perm_indices::new_shrunk_vector): New
function.
* vec-perm-indices.h (vec_perm_indices::new_shrunk_vector): New
declare.

gcc/testsuite/ChangeLog:

PR tree-optimization/99398
* gcc.target/powerpc/vec-perm-ctor-run.c: New test.
* gcc.target/powerpc/vec-perm-ctor.c: New test.
* gcc.target/powerpc/vec-perm-ctor.h: New test.
gcc/testsuite/gcc.target/powerpc/vec-perm-ctor-run.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/vec-perm-ctor.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/vec-perm-ctor.h [new file with mode: 0644]
gcc/tree-ssa-forwprop.c
gcc/vec-perm-indices.c
gcc/vec-perm-indices.h