summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2018-10-17 11:34:32 -0500
committerEmil Velikov <emil.l.velikov@gmail.com>2019-01-11 20:35:35 +0000
commit79c865f2310df6b843702bc47d3393d125801701 (patch)
tree0e44f3cbb942710247c17f6b45383b23e6c34204
parent37a8e85fa4accae9bba35d2a08f619ae2dc5ca8c (diff)
intel/peephole_ffma: Fix swizzle propagation
The num_components value passed into get_mul_for_src is used to only compose the parts of the swizzle that we know will be used so we don't compose invalid swizzle components. However, we had a bug where we passed the number of components of the add all the way through. For the given source, we need the number of components read from that source. In the case where we have a narrow add, say 2 components, that is sourced from a chain of wider instructions, we may not compose all the swizzles. All we really need to do is pass through the right number of components at each level. Fixes: 2231cf0ba3a "nir: Fix output swizzle in get_mul_for_src" Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> (cherry picked from commit 1ede463b6e66eb0a6df5250261810b6985c35eb9)
-rw-r--r--src/intel/compiler/brw_nir_opt_peephole_ffma.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/intel/compiler/brw_nir_opt_peephole_ffma.c b/src/intel/compiler/brw_nir_opt_peephole_ffma.c
index cc225e1847b..7271bdbca43 100644
--- a/src/intel/compiler/brw_nir_opt_peephole_ffma.c
+++ b/src/intel/compiler/brw_nir_opt_peephole_ffma.c
@@ -68,7 +68,7 @@ are_all_uses_fadd(nir_ssa_def *def)
}
static nir_alu_instr *
-get_mul_for_src(nir_alu_src *src, int num_components,
+get_mul_for_src(nir_alu_src *src, unsigned num_components,
uint8_t swizzle[4], bool *negate, bool *abs)
{
uint8_t swizzle_tmp[4];
@@ -93,16 +93,19 @@ get_mul_for_src(nir_alu_src *src, int num_components,
switch (alu->op) {
case nir_op_imov:
case nir_op_fmov:
- alu = get_mul_for_src(&alu->src[0], num_components, swizzle, negate, abs);
+ alu = get_mul_for_src(&alu->src[0], alu->dest.dest.ssa.num_components,
+ swizzle, negate, abs);
break;
case nir_op_fneg:
- alu = get_mul_for_src(&alu->src[0], num_components, swizzle, negate, abs);
+ alu = get_mul_for_src(&alu->src[0], alu->dest.dest.ssa.num_components,
+ swizzle, negate, abs);
*negate = !*negate;
break;
case nir_op_fabs:
- alu = get_mul_for_src(&alu->src[0], num_components, swizzle, negate, abs);
+ alu = get_mul_for_src(&alu->src[0], alu->dest.dest.ssa.num_components,
+ swizzle, negate, abs);
*negate = false;
*abs = true;
break;