mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-12 16:08:19 +02:00
nir/algebraic: remove ignore_exact
This was used because the exact bit meant something different for comparisons than it did for the replacement expression, but that isn't the case anymore. Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Georg Lehmann <dadschoorse@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39809>
This commit is contained in:
parent
f44de53586
commit
fd22c48b2a
5 changed files with 22 additions and 29 deletions
|
|
@ -208,7 +208,6 @@ class Value(object):
|
|||
% elif isinstance(val, Expression):
|
||||
${val.fp_math_ctrl_exclude()},
|
||||
${val.fp_math_ctrl_add()},
|
||||
${'true' if val.ignore_exact else 'false'},
|
||||
${'true' if len(val.sources) > 1 and isinstance(val.sources[1], Constant) else 'false'},
|
||||
${val.swizzle},
|
||||
${val.c_opcode()},
|
||||
|
|
@ -403,7 +402,6 @@ class Expression(Value):
|
|||
self.nnan = cond.pop('nnan', False)
|
||||
self.ninf = cond.pop('ninf', False)
|
||||
self.contract = cond.pop('contract', False) or fp_ctrl == ForceFpCtrl.Contract
|
||||
self.ignore_exact = cond.pop('ignore_exact', False)
|
||||
self.preserve_nan_inf = cond.pop('preserve_nan_inf', False)
|
||||
self.preserve_sz = cond.pop('preserve_sz', False)
|
||||
if cond.pop('preserve_nan_inf_sz', False):
|
||||
|
|
|
|||
|
|
@ -364,13 +364,13 @@ optimizations += [
|
|||
|
||||
# Optimize open-coded fmulz.
|
||||
# (b==0.0 ? 0.0 : a) * (a==0.0 ? 0.0 : b) -> fmulz(a, b)
|
||||
*add_fabs_fneg((('fmul@32(nsz)', ('bcsel', ('feq(ignore_exact)', b, 0.0), 0.0, 'ma'), ('bcsel', ('feq(ignore_exact)', a, 0.0), 0.0, 'mb')),
|
||||
*add_fabs_fneg((('fmul@32(nsz)', ('bcsel', ('feq', b, 0.0), 0.0, 'ma'), ('bcsel', ('feq', a, 0.0), 0.0, 'mb')),
|
||||
('fmulz', 'ma', 'mb'), has_fmulz), {'ma' : a, 'mb' : b}),
|
||||
# (b!=0.0 ? a : 0.0) * (a==0.0 ? 0.0 : b) -> fmulz(a, b)
|
||||
*add_fabs_fneg((('fmul@32(nsz)', ('bcsel', ('fneu(ignore_exact)', b, 0.0), 'ma', 0.0), ('bcsel', ('feq(ignore_exact)', a, 0.0), 0.0, 'mb')),
|
||||
*add_fabs_fneg((('fmul@32(nsz)', ('bcsel', ('fneu', b, 0.0), 'ma', 0.0), ('bcsel', ('feq', a, 0.0), 0.0, 'mb')),
|
||||
('fmulz', 'ma', 'mb'), has_fmulz), {'ma' : a, 'mb' : b}),
|
||||
# (b!=0.0 ? a : 0.0) * (a!=0.0 ? b : 0.0) -> fmulz(a, b)
|
||||
*add_fabs_fneg((('fmul@32(nsz)', ('bcsel', ('fneu(ignore_exact)', b, 0.0), 'ma', 0.0), ('bcsel', ('fneu(ignore_exact)', a, 0.0), 'mb', 0.0)),
|
||||
*add_fabs_fneg((('fmul@32(nsz)', ('bcsel', ('fneu', b, 0.0), 'ma', 0.0), ('bcsel', ('fneu', a, 0.0), 'mb', 0.0)),
|
||||
('fmulz', 'ma', 'mb'), has_fmulz), {'ma' : a, 'mb' : b}),
|
||||
|
||||
# (min(abs(a), abs(b)) == 0.0 ? 0.0 : a * b) -> fmulz(a,b)
|
||||
|
|
@ -378,20 +378,20 @@ optimizations += [
|
|||
('fmulz', 'ma', 'mb'), has_fmulz), {'ma': a, 'mb': b}),
|
||||
|
||||
# a * (a == 0.0 ? 0.0 : b(is_non_const_zero))
|
||||
*add_fabs_fneg((('fmul@32(nsz)', 'ma', ('bcsel', ('feq(ignore_exact)', a, 0.0), 0.0, '#b(is_not_const_zero)')),
|
||||
*add_fabs_fneg((('fmul@32(nsz)', 'ma', ('bcsel', ('feq', a, 0.0), 0.0, '#b(is_not_const_zero)')),
|
||||
('fmulz', 'ma', b), has_fmulz), {'ma' : a}),
|
||||
|
||||
# ffma(b==0.0 ? 0.0 : a, a==0.0 ? 0.0 : b, c) -> ffmaz(a, b, c)
|
||||
*add_fabs_fneg((('ffma@32(nsz)', ('bcsel', ('feq(ignore_exact)', b, 0.0), 0.0, 'ma'), ('bcsel', ('feq(ignore_exact)', a, 0.0), 0.0, 'mb'), c),
|
||||
*add_fabs_fneg((('ffma@32(nsz)', ('bcsel', ('feq', b, 0.0), 0.0, 'ma'), ('bcsel', ('feq', a, 0.0), 0.0, 'mb'), c),
|
||||
('ffmaz', 'ma', 'mb', c), has_fmulz), {'ma' : a, 'mb' : b}),
|
||||
*add_fabs_fneg((('ffma@32(nsz)', 'ma', ('bcsel', ('feq(ignore_exact)', a, 0.0), 0.0, '#b(is_not_const_zero)'), c),
|
||||
*add_fabs_fneg((('ffma@32(nsz)', 'ma', ('bcsel', ('feq', a, 0.0), 0.0, '#b(is_not_const_zero)'), c),
|
||||
('ffmaz', 'ma', b, c), has_fmulz), {'ma' : a}),
|
||||
|
||||
# b == 0.0 ? 1.0 : fexp2(fmul(a, b)) -> fexp2(fmulz(a, b))
|
||||
*add_fabs_fneg((('bcsel(nsz,nnan,ninf)', ('feq(ignore_exact)', b, 0.0), 1.0, ('fexp2', ('fmul@32', a, 'mb'))),
|
||||
*add_fabs_fneg((('bcsel(nsz,nnan,ninf)', ('feq', b, 0.0), 1.0, ('fexp2', ('fmul@32', a, 'mb'))),
|
||||
('fexp2', ('fmulz', a, 'mb')),
|
||||
has_fmulz), {'mb': b}),
|
||||
*add_fabs_fneg((('bcsel', ('feq(ignore_exact)', b, 0.0), 1.0, ('fexp2', ('fmulz', a, 'mb'))),
|
||||
*add_fabs_fneg((('bcsel', ('feq', b, 0.0), 1.0, ('fexp2', ('fmulz', a, 'mb'))),
|
||||
('fexp2', ('fmulz', a, 'mb'))), {'mb': b}),
|
||||
]
|
||||
|
||||
|
|
@ -787,10 +787,10 @@ optimizations.extend([
|
|||
|
||||
(('bcsel(is_only_used_as_float)', ('feq', a, 'b(is_not_zero)'), b, a), a),
|
||||
(('bcsel(is_only_used_as_float)', ('fneu', a, 'b(is_not_zero)'), a, b), a),
|
||||
(('bcsel', ('feq(ignore_exact)', a, 0), 0, ('fsat', ('fmul', a, 'b(is_a_number)'))), ('fsat(preserve_sz)', ('fmul', a, b))),
|
||||
(('bcsel', ('fneu(ignore_exact)', a, 0), ('fsat', ('fmul', a, 'b(is_a_number)')), 0), ('fsat(preserve_sz)', ('fmul', a, b))),
|
||||
(('bcsel', ('feq(ignore_exact)', a, 0), b, ('fadd', a, 'b(is_not_zero)')), ('fadd', a, b)),
|
||||
(('bcsel', ('fneu(ignore_exact)', a, 0), ('fadd', a, 'b(is_not_zero)'), b), ('fadd', a, b)),
|
||||
(('bcsel', ('feq', a, 0), 0, ('fsat', ('fmul', a, 'b(is_a_number)'))), ('fsat(preserve_sz)', ('fmul', a, b))),
|
||||
(('bcsel', ('fneu', a, 0), ('fsat', ('fmul', a, 'b(is_a_number)')), 0), ('fsat(preserve_sz)', ('fmul', a, b))),
|
||||
(('bcsel', ('feq', a, 0), b, ('fadd', a, 'b(is_not_zero)')), ('fadd', a, b)),
|
||||
(('bcsel', ('fneu', a, 0), ('fadd', a, 'b(is_not_zero)'), b), ('fadd', a, b)),
|
||||
|
||||
# 0.0 >= b2f(a)
|
||||
# b2f(a) <= 0.0
|
||||
|
|
|
|||
|
|
@ -374,12 +374,10 @@ match_expression(const nir_algebraic_table *table, const nir_search_expression *
|
|||
instr->def.bit_size != expr->value.bit_size)
|
||||
return false;
|
||||
|
||||
unsigned fp_math_ctrl = instr->fp_math_ctrl & ~(expr->ignore_exact ? nir_fp_exact : 0);
|
||||
|
||||
if (expr->fp_math_ctrl_exclude & fp_math_ctrl)
|
||||
if (expr->fp_math_ctrl_exclude & instr->fp_math_ctrl)
|
||||
return false;
|
||||
|
||||
state->fp_math_ctrl |= fp_math_ctrl;
|
||||
state->fp_math_ctrl |= instr->fp_math_ctrl;
|
||||
|
||||
assert(nir_op_infos[instr->op].num_inputs > 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -136,9 +136,6 @@ typedef struct {
|
|||
/** In a replacement, add these fp_math_ctrl flags to the instruction. */
|
||||
unsigned fp_math_ctrl_add : NIR_FP_MATH_CONTROL_BIT_COUNT;
|
||||
|
||||
/** Don't make the replacement exact if the search expression is exact. */
|
||||
bool ignore_exact : 1;
|
||||
|
||||
/** Whether the second source is a nir_search_value_constant */
|
||||
bool src1_is_const : 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -129,16 +129,16 @@ def main():
|
|||
import nir_algebraic # pylint: disable=import-error
|
||||
|
||||
r300_nir_lower_bool_to_float = [
|
||||
(('bcsel@32(is_only_used_as_float)', ('feq(ignore_exact)', 'a@32', 'b@32'), c, d),
|
||||
(('bcsel@32(is_only_used_as_float)', ('feq', 'a@32', 'b@32'), c, d),
|
||||
('fadd', ('fmul', c, ('seq', a, b)), ('fsub', d, ('fmul', d, ('seq', a, b)))),
|
||||
"!options->has_fused_comp_and_csel"),
|
||||
(('bcsel@32(is_only_used_as_float)', ('fneu(ignore_exact)', 'a@32', 'b@32'), c, d),
|
||||
(('bcsel@32(is_only_used_as_float)', ('fneu', 'a@32', 'b@32'), c, d),
|
||||
('fadd', ('fmul', c, ('sne', a, b)), ('fsub', d, ('fmul', d, ('sne', a, b)))),
|
||||
"!options->has_fused_comp_and_csel"),
|
||||
(('bcsel@32(is_only_used_as_float)', ('flt(ignore_exact)', 'a@32', 'b@32'), c, d),
|
||||
(('bcsel@32(is_only_used_as_float)', ('flt', 'a@32', 'b@32'), c, d),
|
||||
('fadd', ('fmul', c, ('slt', a, b)), ('fsub', d, ('fmul', d, ('slt', a, b)))),
|
||||
"!options->has_fused_comp_and_csel"),
|
||||
(('bcsel@32(is_only_used_as_float)', ('fge(ignore_exact)', 'a@32', 'b@32'), c, d),
|
||||
(('bcsel@32(is_only_used_as_float)', ('fge', 'a@32', 'b@32'), c, d),
|
||||
('fadd', ('fmul', c, ('sge', a, b)), ('fsub', d, ('fmul', d, ('sge', a, b)))),
|
||||
"!options->has_fused_comp_and_csel"),
|
||||
(('bcsel@32(is_only_used_as_float)', ('feq', 'a@32', 'b@32'), c, d),
|
||||
|
|
@ -152,13 +152,13 @@ def main():
|
|||
]
|
||||
|
||||
r300_nir_lower_bool_to_float_fs = [
|
||||
(('bcsel@32(r300_is_only_used_as_float)', ('feq(ignore_exact)', 'a@32', 'b@32'), c, d),
|
||||
(('bcsel@32(r300_is_only_used_as_float)', ('feq', 'a@32', 'b@32'), c, d),
|
||||
('fcsel_ge', ('fneg', ('fabs', ('fadd', a, ('fneg', b)))), c, d)),
|
||||
(('bcsel@32(r300_is_only_used_as_float)', ('fneu(ignore_exact)', 'a@32', 'b@32'), c, d),
|
||||
(('bcsel@32(r300_is_only_used_as_float)', ('fneu', 'a@32', 'b@32'), c, d),
|
||||
('fcsel_ge', ('fneg', ('fabs', ('fadd', a, ('fneg', b)))), d, c)),
|
||||
(('bcsel@32(r300_is_only_used_as_float)', ('flt(ignore_exact)', 'a@32', 'b@32'), c, d),
|
||||
(('bcsel@32(r300_is_only_used_as_float)', ('flt', 'a@32', 'b@32'), c, d),
|
||||
('fcsel_ge', ('fadd', a, ('fneg', b)), d, c)),
|
||||
(('bcsel@32(r300_is_only_used_as_float)', ('fge(ignore_exact)', 'a@32', 'b@32'), c, d),
|
||||
(('bcsel@32(r300_is_only_used_as_float)', ('fge', 'a@32', 'b@32'), c, d),
|
||||
('fcsel_ge', ('fadd', a, ('fneg', b)), c, d)),
|
||||
(('b2f32', ('feq', 'a@32', 'b@32')),
|
||||
('fcsel_ge', ('fneg', ('fabs', ('fadd', a, ('fneg', b)))), 1.0, 0.0)),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue