On Mon, Jun 7, 2021 at 12:12 AM Richard Sandiford <richard.sandif...@arm.com> wrote: > > "H.J. Lu" <hjl.to...@gmail.com> writes: > > Update vec_duplicate to allow to fail so that backend can only allow > > broadcasting an integer constant to a vector when broadcast instruction > > is available. > > I'm not sure why we need this to fail though. Once the optab is defined > for target X, the optab should handle all duplicates for target X, > even if there are different strategies it can use. > > AIUI the case you want to make conditional is the constant case. > I guess the first question is: why don't we simplify those CONSTRUCTORs > to VECTOR_CSTs in gimple? I'm surprised we still see the constant case > as a constructor here.
The particular testcase for vec_duplicate is gcc.dg/pr100239.c. > If we can't rely on that happening, then would it work to change: > > /* Try using vec_duplicate_optab for uniform vectors. */ > if (!TREE_SIDE_EFFECTS (exp) > && VECTOR_MODE_P (mode) > && eltmode == GET_MODE_INNER (mode) > && ((icode = optab_handler (vec_duplicate_optab, mode)) > != CODE_FOR_nothing) > && (elt = uniform_vector_p (exp))) > > to something like: > > /* Try using vec_duplicate_optab for uniform vectors. */ > if (!TREE_SIDE_EFFECTS (exp) > && VECTOR_MODE_P (mode) > && eltmode == GET_MODE_INNER (mode) > && (elt = uniform_vector_p (exp))) > { > if (TREE_CODE (elt) == INTEGER_CST > || TREE_CODE (elt) == POLY_INT_CST > || TREE_CODE (elt) == REAL_CST > || TREE_CODE (elt) == FIXED_CST) > { > rtx src = gen_const_vec_duplicate (mode, expand_normal > (node)); > emit_move_insn (target, src); > break; > } > … > } I will give it a try. Thanks. -- H.J.