# Float sizes
for s in [16, 32, 64]:
+ if s == 64:
+ match_fsign_cond = "!options->lower_fsign & !(options->lower_doubles_options & nir_lower_dsign)"
+ else:
+ match_fsign_cond = "!options->lower_fsign"
optimizations.extend([
# These derive from the previous patterns with the application of b < 0 <=>
# 0 < -b. The transformation should be applied if either comparison is
(('~f2u{}'.format(s), ('i2f', 'a@{}'.format(s))), a),
(('~f2u{}'.format(s), ('u2f', 'a@{}'.format(s))), a),
- (('fadd', ('b2f{}'.format(s), ('flt', 0.0, 'a@{}'.format(s))), ('fneg', ('b2f{}'.format(s), ('flt', 'a@{}'.format(s), 0.0)))), ('fsign', a), '!options->lower_fsign'),
- (('iadd', ('b2i{}'.format(s), ('flt', 0, 'a@{}'.format(s))), ('ineg', ('b2i{}'.format(s), ('flt', 'a@{}'.format(s), 0)))), ('f2i{}'.format(s), ('fsign', a)), '!options->lower_fsign'),
+ (('fadd', ('b2f{}'.format(s), ('flt', 0.0, 'a@{}'.format(s))), ('fneg', ('b2f{}'.format(s), ('flt', 'a@{}'.format(s), 0.0)))), ('fsign', a), match_fsign_cond),
+ (('iadd', ('b2i{}'.format(s), ('flt', 0, 'a@{}'.format(s))), ('ineg', ('b2i{}'.format(s), ('flt', 'a@{}'.format(s), 0)))), ('f2i{}'.format(s), ('fsign', a)), match_fsign_cond),
# float? -> float? -> floatS ==> float? -> floatS
(('~f2f{}'.format(s), ('f2f', a)), ('f2f{}'.format(s), a)),
# Mark the new comparisons precise to prevent them being changed to 'a !=
# 0' or 'a == 0'.
(('fsign', a), ('fsub', ('b2f', ('!flt', 0.0, a)), ('b2f', ('!flt', a, 0.0))), 'options->lower_fsign'),
+ (('fsign', 'a@64'), ('fsub', ('b2f', ('!flt', 0.0, a)), ('b2f', ('!flt', a, 0.0))), 'options->lower_doubles_options & nir_lower_dsign'),
# Address/offset calculations:
# Drivers supporting imul24 should use the nir_lower_amul() pass, this