(('b2f(is_used_more_than_once)', ('inot', a)), ('bcsel', a, 0.0, 1.0)),
(('fneg(is_used_more_than_once)', ('b2f', ('inot', a))), ('bcsel', a, -0.0, -1.0)),
+
+ # we do these late so that we don't get in the way of creating ffmas
+ (('fmin', ('fadd(is_used_once)', '#c', a), ('fadd(is_used_once)', '#c', b)), ('fadd', c, ('fmin', a, b))),
+ (('fmax', ('fadd(is_used_once)', '#c', a), ('fadd(is_used_once)', '#c', b)), ('fadd', c, ('fmax', a, b))),
]
print nir_algebraic.AlgebraicPass("nir_opt_algebraic", optimizations).render()
return true;
}
+static inline bool
+is_used_once(nir_alu_instr *instr)
+{
+ bool zero_if_use = list_empty(&instr->dest.dest.ssa.if_uses);
+ bool zero_use = list_empty(&instr->dest.dest.ssa.uses);
+
+ if (zero_if_use && zero_use)
+ return false;
+
+ if (!zero_if_use && list_is_singular(&instr->dest.dest.ssa.uses))
+ return false;
+
+ if (!zero_use && list_is_singular(&instr->dest.dest.ssa.if_uses))
+ return false;
+
+ if (!list_is_singular(&instr->dest.dest.ssa.if_uses) &&
+ !list_is_singular(&instr->dest.dest.ssa.uses))
+ return false;
+
+ return true;
+}
+
static inline bool
is_not_used_by_if(nir_alu_instr *instr)
{