diff --git a/gcc/match.pd b/gcc/match.pd index c2fed9b..753c392 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -7800,6 +7800,22 @@ and, (if (TREE_CODE (@0) == SSA_NAME && num_imm_uses (@0) == 2) (minus (mult (vec_perm @1 @1 @3) @2) @4))) +/* VEC_UNPACK_LO_EXPR and friends. */ +(for unpack (vec_unpack_lo vec_unpack_float_lo vec_unpack_fix_trunc_lo + vec_unpack_hi vec_unpack_float_hi vec_unpack_fix_trunc_hi) + opcode (convert float fix_trunc convert float fix_trunc) + (simplify + (unpack CONSTRUCTOR@0) + (with { tree ctor = (TREE_CODE (@0) == SSA_NAME + ? gimple_assign_rhs1 (SSA_NAME_DEF_STMT (@0)) : @0); + tree elt = uniform_vector_p (ctor); + tree eltype = TREE_TYPE (type); } + (if (elt) + (vec_duplicate (opcode:eltype { elt; }))))) + (simplify + (unpack (vec_duplicate @0)) + (with { tree eltype = TREE_TYPE (type); } + (vec_duplicate (opcode:eltype @0))))) /* Match count trailing zeroes for simplify_count_trailing_zeroes in fwprop. The canonical form is array[((x & -x) * C) >> SHIFT] where C is a magic diff --git a/gcc/testsuite/g++.dg/vect/pr105621.cc b/gcc/testsuite/g++.dg/vect/pr105621.cc new file mode 100644 index 0000000..98e8fcd --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/pr105621.cc @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +bool d; + +void test(unsigned short a, int b, unsigned c) { + for (int i = 2; i < 24; i += 3) + d = b ? a ? c : 2086607777901731118 : 0; +} + +/* { dg-final { scan-tree-dump-not "vec_unpack" "optimized" } } */