[Mesa-dev] [PATCH 4/6] nir: Add a local variable-based copy propagation pass

Jason Ekstrand jason at jlekstrand.net
Tue Dec 13 22:43:46 UTC 2016


On Tue, Dec 13, 2016 at 9:43 AM, Eric Anholt <eric at anholt.net> wrote:

> Jason Ekstrand <jason at jlekstrand.net> writes:
>
> > diff --git a/src/compiler/nir/nir_opt_copy_prop_vars.c
> b/src/compiler/nir/nir_opt_copy_prop_vars.c
> > new file mode 100644
> > index 0000000..728e476
> > --- /dev/null
> > +++ b/src/compiler/nir/nir_opt_copy_prop_vars.c
> > @@ -0,0 +1,799 @@
> > +/*
> > + * Copyright © 2016 Intel Corporation
> > + *
> > + * Permission is hereby granted, free of charge, to any person
> obtaining a
> > + * copy of this software and associated documentation files (the
> "Software"),
> > + * to deal in the Software without restriction, including without
> limitation
> > + * the rights to use, copy, modify, merge, publish, distribute,
> sublicense,
> > + * and/or sell copies of the Software, and to permit persons to whom the
> > + * Software is furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice (including the
> next
> > + * paragraph) shall be included in all copies or substantial portions
> of the
> > + * Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> EXPRESS OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT
> SHALL
> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
> OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> ARISING
> > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> DEALINGS
> > + * IN THE SOFTWARE.
> > + */
> > +
> > +#include "nir.h"
> > +#include "nir_builder.h"
> > +
> > +/**
> > + * Variable-based copy propagation
> > + *
> > + * Normally, NIR trusts in SSA form for most of its copy-propagation
> needs.
> > + * However, there are cases, especially when dealing with indirects,
> where SSA
> > + * won't help you.  This pass is for those times.  Specifically, it
> handles
> > + * the following things that the rest of NIR can't:
> > + *
> > + *  1) Copy-propagation on variables that have indirect access.  This
> includes
> > + *     propagating from indirect stores into indirect loads.
> > + *
> > + *  2) Dead code elimination of store_var and copy_var intrinsics based
> on
> > + *     killed destination values.
> > + *
> > + *  3) Removal of redundant load_var intrinsics.  We can't trust
> regular CSE
> > + *     to do this because it isn't aware of variable writes that may
> alias the
> > + *     value and make the former load invalid.
> > + *
> > + * Unfortunately, properly handling all of those cases makes this path
> rather
> > + * complex.  In order to avoid additional complexity, this pass is
> entirely
> > + * block-local.  If we tried to make it local the data-flow analysis
> would
>
> I think here you wanted to say "make it global."
>

Thanks.  Fixed locally.


> I haven't reviewed the rest, I was just skimming to see what you were up
> to.
>
> > + * rapidly get out of hand.  Fortunately, for anything that is only ever
> > + * accessed directly, we get SSA based copy-propagation which is
> extremely
> > + * powerful so this isn't that great a loss.
> > + */
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161213/9b65bcd8/attachment.html>


More information about the mesa-dev mailing list