<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Dec 13, 2016 at 9:43 AM, Eric Anholt <span dir="ltr"><<a href="mailto:eric@anholt.net" target="_blank">eric@anholt.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> writes:<br>
<br>
> diff --git a/src/compiler/nir/nir_opt_<wbr>copy_prop_vars.c b/src/compiler/nir/nir_opt_<wbr>copy_prop_vars.c<br>
> new file mode 100644<br>
> index 0000000..728e476<br>
> --- /dev/null<br>
> +++ b/src/compiler/nir/nir_opt_<wbr>copy_prop_vars.c<br>
> @@ -0,0 +1,799 @@<br>
> +/*<br>
> + * Copyright © 2016 Intel Corporation<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice (including the next<br>
> + * paragraph) shall be included in all copies or substantial portions of the<br>
> + * Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
> + * IN THE SOFTWARE.<br>
> + */<br>
> +<br>
> +#include "nir.h"<br>
> +#include "nir_builder.h"<br>
> +<br>
> +/**<br>
> + * Variable-based copy propagation<br>
> + *<br>
> + * Normally, NIR trusts in SSA form for most of its copy-propagation needs.<br>
> + * However, there are cases, especially when dealing with indirects, where SSA<br>
> + * won't help you. This pass is for those times. Specifically, it handles<br>
> + * the following things that the rest of NIR can't:<br>
> + *<br>
> + * 1) Copy-propagation on variables that have indirect access. This includes<br>
> + * propagating from indirect stores into indirect loads.<br>
> + *<br>
> + * 2) Dead code elimination of store_var and copy_var intrinsics based on<br>
> + * killed destination values.<br>
> + *<br>
> + * 3) Removal of redundant load_var intrinsics. We can't trust regular CSE<br>
> + * to do this because it isn't aware of variable writes that may alias the<br>
> + * value and make the former load invalid.<br>
> + *<br>
> + * Unfortunately, properly handling all of those cases makes this path rather<br>
> + * complex. In order to avoid additional complexity, this pass is entirely<br>
> + * block-local. If we tried to make it local the data-flow analysis would<br>
<br>
</div></div>I think here you wanted to say "make it global."<br></blockquote><div><br></div><div>Thanks. Fixed locally.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I haven't reviewed the rest, I was just skimming to see what you were up<br>
to.<br>
<div class="HOEnZb"><div class="h5"><br>
> + * rapidly get out of hand. Fortunately, for anything that is only ever<br>
> + * accessed directly, we get SSA based copy-propagation which is extremely<br>
> + * powerful so this isn't that great a loss.<br>
> + */<br>
</div></div></blockquote></div><br></div></div>