[Mesa-dev] [PATCH v3 3/3] glsl: propagate full variables eagerly
Caio Marcelo de Oliveira Filho
caio.oliveira at intel.com
Fri Jul 27 18:13:01 UTC 2018
Hi Thomas,
On Thu, Jul 26, 2018 at 09:59:44PM +0200, Thomas Helland wrote:
> Since we're always going top-down through the
> program there should be no need to "walk backwards",
> so this approach should be enough to get the whole chain
> of assignments in one pass. Neat.
The patch that incorporates full variables in the elements pass was
already fixing up the ir_dereference_variables when visiting them
(that happens before the visit to the assignments), so this turned out
not to be needed.
So we have
b = a
- dereference visit for 'a': there's no acp_entry for 'a'
- assignment visit: creates acp_entry for (b, a)
c = b
- dereference visit for 'b': there's acp_entry for 'b', use it
>>> c = a
- assignment visit: creates acp_entry for (c, a)
...
I was initially experimenting with the same idea for elements, which
don't have the "dereference visit" so such idea would make sense, but
that turned out not to be so useful.
Thanks,
Caio
> 2018-07-25 3:03 GMT+02:00 Caio Marcelo de Oliveira Filho
> <caio.oliveira at intel.com>:
> > When creating a new acp_entry after an assignment "c = b", check if b
> > itself has an acp_entry with a full variable associated and use
> > that. This reduces the number of passes the algorithm needs to
> > propagate a value in a chain of assignments.
> >
> > I've tried to make a similar change to the write_partial, but it
> > caused noise in the final output (hurting instruction count). The
> > reason is for partials, a propagation might imply a swizzle
> > operation.
> >
> > We could later investigate if it is worth to restrict the cases we are
> > eager to avoid getting things worse because of swizzling.
> > ---
> > .../glsl/opt_copy_propagation_elements.cpp | 23 ++++++++++++++++++-
> > 1 file changed, 22 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/compiler/glsl/opt_copy_propagation_elements.cpp b/src/compiler/glsl/opt_copy_propagation_elements.cpp
> > index cae6d3c0707..c44f7c56f11 100644
> > --- a/src/compiler/glsl/opt_copy_propagation_elements.cpp
> > +++ b/src/compiler/glsl/opt_copy_propagation_elements.cpp
> > @@ -169,8 +169,29 @@ public:
> > }
> > }
> >
> > + /* If the rhs has an acp_entry pointing to another full variable, use
> > + * that. This allows propagation to happen all in one pass, instead of
> > + * having the value walking slowly. E.g.
> > + *
> > + * b = a
> > + * c = b
> > + * d = c
> > + * use(d)
> > + *
> > + * will need one pass to propagate to
> > + *
> > + * b = a
> > + * c = a // Because of b acp_entry.
> > + * d = a // Because of c acp_entry that uses 'a' directly.
> > + * use(a) // Because of d acp_entry that uses 'a' directly.
> > + */
> > + acp_entry *rhs_entry = read(rhs);
> > + if (rhs_entry && rhs_entry->rhs_full != NULL) {
> > + rhs = rhs_entry->rhs_full;
> > + }
> > + rhs_entry = pull_acp(rhs);
> > +
> > lhs_entry->rhs_full = rhs;
> > - acp_entry *rhs_entry = pull_acp(rhs);
> > _mesa_set_add(rhs_entry->dsts, lhs);
> >
> > if (lhs->type->is_vector()) {
> > --
> > 2.18.0
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list