https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94710
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- For the middle-end side, I think we can do: 2020-04-23 Jakub Jelinek <ja...@redhat.com> PR target/94710 * optabs.c (expand_vec_perm_const): For shift_amt const0_rtx just return v2. --- gcc/optabs.c.jj 2020-04-17 14:18:44.380437703 +0200 +++ gcc/optabs.c 2020-04-23 11:50:07.931780323 +0200 @@ -5627,6 +5627,8 @@ expand_vec_perm_const (machine_mode mode if (shift_amt) { class expand_operand ops[3]; + if (shift_amt == const0_rtx) + return v2; if (shift_code != CODE_FOR_nothing) { create_output_operand (&ops[0], target, mode); Though, the backend shouldn't rely on the middle-end doing this optimization.