nir: fix a bug with constant folding non-per-component instructions
authorConnor Abbott <cwabbott0@gmail.com>
Sun, 25 Jan 2015 16:47:53 +0000 (11:47 -0500)
committerConnor Abbott <cwabbott0@gmail.com>
Tue, 27 Jan 2015 02:26:36 +0000 (21:26 -0500)
Before, we were only copying the first N channels, where N is the size
of the SSA destination, which is fine for per-component instructions,
but non-per-component instructions like fdot3 can have more source
components than destination components. Fix this using the helper
function introduced in the last patch.

v2: use new helper name

Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Signed-off-by: Connor Abbott <cwabbott0@gmail.com>
src/glsl/nir/nir_opt_constant_folding.c

index f727453b321e59e2a5f7b35721be5c948024d256..85c09fc4800db9b99d2bcc3df744392a3b1239f7 100644 (file)
@@ -56,7 +56,8 @@ constant_fold_alu_instr(nir_alu_instr *instr, void *mem_ctx)
          return false;
       nir_load_const_instr* load_const = nir_instr_as_load_const(src_instr);
 
-      for (unsigned j = 0; j < instr->dest.dest.ssa.num_components; j++) {
+      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]];
       }