https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99398
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Kewen Lin <li...@gcc.gnu.org>: https://gcc.gnu.org/g:4a9f2306cb39a3cf265eeb6f8f3a8bbaf230c4c8 commit r12-1103-g4a9f2306cb39a3cf265eeb6f8f3a8bbaf230c4c8 Author: Kewen Lin <li...@linux.ibm.com> Date: Fri May 28 01:11:45 2021 -0500 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.