This is the mail archive of the
mailing list for the GCC project.
Re: [5/6] Insert pattern statements into vec_basic_blocks
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Richard Sandiford <richard dot sandiford at arm dot com>
- Date: Wed, 29 Aug 2018 11:22:34 +0200
- Subject: Re: [5/6] Insert pattern statements into vec_basic_blocks
- References: <firstname.lastname@example.org> <email@example.com> <20180829075547.GU2218@tucnak> <firstname.lastname@example.org> <20180829090715.GX2218@tucnak>
On Wed, Aug 29, 2018 at 11:10 AM Jakub Jelinek <email@example.com> wrote:
> On Wed, Aug 29, 2018 at 09:59:07AM +0100, Richard Sandiford wrote:
> > Jakub Jelinek <firstname.lastname@example.org> writes:
> > > On Tue, Aug 28, 2018 at 12:24:06PM +0100, Richard Sandiford wrote:
> > >> The point of this patch is to put pattern statements in the same
> > >> vec_basic_block as the statements they replace, with the pattern
> > >> statements for S coming between S and S's original predecessor.
> > >> This removes the need to handle them specially in various places.
> > >
> > > My preferred way to handle pattern stmts would be to do what we do in
> > > tree-if-conversion, i.e. whenever creating first pattern stmt for certain
> > > loop, duplicate that loop directly in the IL guarded with an ifn
> > > and modify directly one copy of the loop (the one meant to be vectorized).
> > > If we aren't cycling over multiple vectorization factors, that could be even
> > > done directly on the tree-if-conversion created vector loop copy, otherwise
> > > we'd need more.
> > I'd originally tried adding the pattern stmts to the gimple bb as well
> > as the vec_basic_block, but the problem is that we create pattern stmts
> > before duplicating the scalar loop for peeling. So I think we'd need to
> > copy the loop even for the single-size case, or arrange some other way of
> > temporarily restoring the original code.
> Sure, if tree-if-conversion doesn't copy the loop and for single-size case,
> we'd need to do that copy (once per loop), if it already copied the loop,
> there is already the scalar and for vectorization only loop.
> With those copies you don't need to roll back anything, just ensure the
> guarding internal fns fold to constants when the vectorization is over based
> on if the loop was vectorized and with what vf, and cfg cleanup will do the
> The vectorizer already has code to find the scalar loop in the
> LOOP_VECTORIZED condition guarded else block.
My hope is still that we can eventually get rid of pattern stmts - I see how
they make things easier, esp. for the issue of computing a vectorization
Note the duplication comes at a cost - we do not version loops for if-conversion
before we know we'll apply if-conversion and it will succeed. It would be
bad if we start to duplicate each loop just because we start vectorization
analysis (and pattern recog is done very early).