This patch simplifies vec_unpack_hi_expr/vec_unpack_lo_expr of a uniform constructor or vec_duplicate operand. The motivation is from PR 105621 where after optimization, we're left with: vect_cst__21 = {c_8(D), c_8(D), c_8(D), c_8(D)}; vect_iftmp.7_4 = [vec_unpack_hi_expr] vect_cst__21; It turns out that there are no constant folding/simplification patterns in match.pd, but the above can be simplified further to the equivalent: _20 = (long int) c_8(D); vect_iftmp.7_4 = [vec_duplicate_expr] _20; which on x86-64 results in one less instruction, replacing pshufd $0 then punpackhq, with punpcklqdq. This transformation is also useful for helping CSE to spot that unpack_hi and unpack_lo are equivalent. This patch has been tested on x86_64-pc-linux-gnu with make bootstrap and make -k check with no new failures. Ok for mainline? 2022-05-21 Roger Sayle gcc/ChangeLog * match.pd (simplify vec_unpack_hi): Simplify VEC_UNPACK_*_EXPR of uniform vector constructors and vec_duplicate. gcc/testsuite/ChangeLog * g++.dg/vect/pr105621.cc: New test case. Thanks in advance, Roger --