nir/search: respect sign of zero when comparing floats

Floating point comparison treats -0.0 and 0.0 as equal,
but do this in nir_search makes patterns signed zero incorrect.

Foz-DB Navi21:
Totals from 1460 (1.16% of 125360) affected shaders:
MaxWaves: 33704 -> 33710 (+0.02%)
Instrs: 2559362 -> 2558823 (-0.02%); split: -0.02%, +0.00%
CodeSize: 14502684 -> 14496352 (-0.04%); split: -0.05%, +0.00%
VGPRs: 71800 -> 71776 (-0.03%)
Latency: 19274782 -> 19274267 (-0.00%); split: -0.01%, +0.00%
InvThroughput: 3307870 -> 3299091 (-0.27%); split: -0.27%, +0.00%
SClause: 158698 -> 158703 (+0.00%); split: -0.00%, +0.00%
Copies: 240291 -> 241003 (+0.30%); split: -0.03%, +0.32%
PreSGPRs: 73203 -> 73206 (+0.00%); split: -0.00%, +0.01%
PreVGPRs: 62515 -> 62508 (-0.01%)
VALU: 1564970 -> 1564331 (-0.04%); split: -0.04%, +0.00%
SALU: 378546 -> 378654 (+0.03%); split: -0.00%, +0.03%

This difference is suprisingly positive, the only patterns affected
did previously signed zero incorrect bcsel -> b2f.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39123>
This commit is contained in:
Georg Lehmann 2026-01-02 09:58:34 +01:00 committed by Marge Bot
parent 7d2a946730
commit 0d255011ae

View file

@ -334,6 +334,12 @@ match_value(const nir_algebraic_table *table,
new_swizzle[i]);
if (val != const_val->data.d)
return false;
/* The comparison above does not check the sign bit for 0.0,
* so do it manually.
*/
if ((dui(val) == 0) != (dui(const_val->data.d) == 0))
return false;
}
return true;
}