intel/nir_opt_peephole_ffma: fix fp_math_ctlr for modifiers

If abs/neg don't preserve nan/inf/sz, the whole expressions won't.

Fixes: 1b0808adf3 ("intel/nir: Make ffma peephole optimization preserve fp_fast_math flags")
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
(cherry picked from commit 26ec32dada)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41269>
This commit is contained in:
Georg Lehmann 2026-04-22 15:04:31 +02:00 committed by Eric Engestrom
parent f7aeeb194d
commit 013936e250
2 changed files with 3 additions and 2 deletions

View file

@ -644,7 +644,7 @@
"description": "intel/nir_opt_peephole_ffma: fix fp_math_ctlr for modifiers",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "1b0808adf3d95c64081e393f021f624f72e86d88",
"notes": null

View file

@ -209,6 +209,7 @@ intel_nir_opt_peephole_ffma_instr(nir_builder *b,
}
b->cursor = nir_before_instr(&add->instr);
b->fp_math_ctrl = mul->fp_math_ctrl | add->fp_math_ctrl;
if (abs) {
for (unsigned i = 0; i < 2; i++)
@ -219,7 +220,7 @@ intel_nir_opt_peephole_ffma_instr(nir_builder *b,
mul_src[0] = nir_fneg(b, mul_src[0]);
nir_alu_instr *ffma = nir_alu_instr_create(b->shader, nir_op_ffma);
ffma->fp_math_ctrl = mul->fp_math_ctrl | add->fp_math_ctrl;
ffma->fp_math_ctrl = b->fp_math_ctrl;
for (unsigned i = 0; i < 2; i++) {
ffma->src[i].src = nir_src_for_ssa(mul_src[i]);