On Fri, 7 May 2021, Kewen.Lin wrote: > Hi, > > This patch is to teach forwprop to optimize some cases where the > permutated operands of vector permutation are from two same type > CTOR and CTOR or one CTOR and one VECTOR CST. It aggressively > takes VIEW_CONVERT_EXPR as trivial copies and transform the vector > permutation into vector CTOR. > > Bootstrapped/regtested on powerpc64le-linux-gnu P9, powerpc64-linux-gnu P8, > x86_64-redhat-linux and aarch64-linux-gnu. > > Is it ok for trunk?
Can you please avoid the changes to get_prop_source_stmt and can_propagate_from? It should work to add a single match of a V_C_E after the get_prop_source_stmt call. Ideally we'd have /* Shuffle of a constructor. */ else if (code == CONSTRUCTOR || code == VECTOR_CST) { ... } else if (code == VIEW_CONVERT_EXPR) { op1 must also be a V_C_E or VECTOR_CST here } but then I fear we have no canonicalization of the VECTOR_CST to 2nd VEC_PERM operand. But then moving the op1 gathering out of the if (code == CONSTRUCTOR || code == VECTOR_CST) case (doesn't need an else) might still make such refactoring possible as first matching if (code == VIEW_CONVERT_EXPR || code2 == VIEW_CONVERT_EXPR) { ... } else if (code == CONSTRUCTOR || code == VECTOR_CST) ... I'd appreciate Richard S. comments on the vec_perm_indices::new_shrinked_vector code. Thanks, Richard. > BR, > Kewen > ------ > gcc/ChangeLog: > > PR tree-optimization/99398 > * tree-ssa-forwprop.c (get_prop_source_stmt): Add optional argument > view_conv_prop to indicate whether to take VIEW_CONVERT_EXPR as > trivial copy. Add handlings for this argument. > (remove_prop_source_from_use): Likewise. > (simplify_permutation): Optimize some cases where the fed operands > are CTOR/CST and propagated through VIEW_CONVERT_EXPR. Add the > call to vec_perm_indices::new_shrinked_vector. > * vec-perm-indices.c (vec_perm_indices::new_shrinked_vector): New > function. > * vec-perm-indices.h (vec_perm_indices::new_shrinked_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. > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)