On Tue, Mar 15, 2016 at 8:41 PM, Eric Anholt <e...@anholt.net> wrote:
> I copy and pasted this code before finding the helper. > --- > src/compiler/nir/nir_opt_constant_folding.c | 10 +++------- > 1 file changed, 3 insertions(+), 7 deletions(-) > > diff --git a/src/compiler/nir/nir_opt_constant_folding.c > b/src/compiler/nir/nir_opt_constant_folding.c > index 8a353c2..190a509 100644 > --- a/src/compiler/nir/nir_opt_constant_folding.c > +++ b/src/compiler/nir/nir_opt_constant_folding.c > @@ -47,18 +47,14 @@ constant_fold_alu_instr(nir_alu_instr *instr, void > *mem_ctx) > return false; > > for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) { > - if (!instr->src[i].src.is_ssa) > - return false; > - > - nir_instr *src_instr = instr->src[i].src.ssa->parent_instr; > + nir_const_value *src_val = > nir_src_as_const_value(instr->src[i].src); > > - if (src_instr->type != nir_instr_type_load_const) > + if (!src_val) > return false; > - nir_load_const_instr* load_const = > nir_instr_as_load_const(src_instr); > > for (unsigned j = 0; j < nir_ssa_alu_instr_src_components(instr, i); > j++) { > - src[i].u[j] = load_const->value.u[instr->src[i].swizzle[j]]; > + src[i].u[j] = src_val->u[instr->src[i].swizzle[j]]; > Much better. Reviewed-by: Jason Ekstrand <ja...@jlekstrand.net> > } > > /* We shouldn't have any source modifiers in the optimization loop. > */ > -- > 2.7.0 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev >
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev