[PATCH] middle-end/100951 - make sure to generate VECTOR_CST in lowering

H.J. Lu hjl.tools@gmail.com
Mon Jun 7 20:33:39 GMT 2021


On Mon, Jun 7, 2021 at 11:10 AM Richard Biener
<richard.guenther@gmail.com> wrote:
>
> On Mon, Jun 7, 2021 at 7:59 PM Richard Biener
> <richard.guenther@gmail.com> wrote:
> >
> > On Mon, Jun 7, 2021 at 4:19 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >
> > > On Mon, Jun 7, 2021 at 12:12 AM Richard Sandiford
> > > <richard.sandiford@arm.com> wrote:
> > > >
> > > > "H.J. Lu" <hjl.tools@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.
> >
> > I can confirm that veclower leaves us with an unfolded constant CTOR.
> > If you file a PR to remind me I'll fix that.
>
> The attached untested patch fixes this for the testcase.
>

Here is the patch + the testcase.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-middle-end-100951-make-sure-to-generate-VECTOR_CST-i.patch
Type: text/x-patch
Size: 5388 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20210607/9d39ed28/attachment.bin>


More information about the Gcc-patches mailing list