<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 15, 2016 at 8:41 PM, 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">I copy and pasted this code before finding the helper.<br>
---<br>
 src/compiler/nir/nir_opt_constant_folding.c | 10 +++-------<br>
 1 file changed, 3 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/src/compiler/nir/nir_opt_constant_folding.c b/src/compiler/nir/nir_opt_constant_folding.c<br>
index 8a353c2..190a509 100644<br>
--- a/src/compiler/nir/nir_opt_constant_folding.c<br>
+++ b/src/compiler/nir/nir_opt_constant_folding.c<br>
@@ -47,18 +47,14 @@ constant_fold_alu_instr(nir_alu_instr *instr, void *mem_ctx)<br>
       return false;<br>
<br>
    for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) {<br>
-      if (!instr->src[i].src.is_ssa)<br>
-         return false;<br>
-<br>
-      nir_instr *src_instr = instr->src[i].src.ssa->parent_instr;<br>
+      nir_const_value *src_val = nir_src_as_const_value(instr->src[i].src);<br>
<br>
-      if (src_instr->type != nir_instr_type_load_const)<br>
+      if (!src_val)<br>
          return false;<br>
-      nir_load_const_instr* load_const = nir_instr_as_load_const(src_instr);<br>
<br>
       for (unsigned j = 0; j < nir_ssa_alu_instr_src_components(instr, i);<br>
            j++) {<br>
-         src[i].u[j] = load_const->value.u[instr->src[i].swizzle[j]];<br>
+         src[i].u[j] = src_val->u[instr->src[i].swizzle[j]];<br></blockquote><div><br></div><div>Much better.<br><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
       }<br>
<br>
       /* We shouldn't have any source modifiers in the optimization loop. */<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.7.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>