From 0710d042db7ee46cd39e61ab7245c1f00712ba88 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 22 Jan 2026 18:28:39 -0800 Subject: [PATCH] elk: Call nir_opt_algebraic_late in elk_postprocess_nir Make sure that lowering undone in elk_nir_optimize are reapplied. No shader-db or fossil-db changes on any Intel platform. This is most likely to impact either Gfx8 on ANV or Gfx7.5 on HASVK. I don't fossil-db test either of those platforms. I tried doing a similar thing here as is done in BRW (previous commit), but that caused a couple Haswell shaders to fall off a performance cliff: total spills in shared programs: 8247 -> 8311 (0.78%) spills in affected programs: 6 -> 70 (1066.67%) helped: 0 / HURT: 2 total fills in shared programs: 8558 -> 8910 (4.11%) fills in affected programs: 6 -> 358 (5866.67%) helped: 0 / HURT: 2 Fixes: 442daeb54a2 ("nir/opt_algebraic: use fcanonicalize") Reviewed-by: Alyssa Rosenzweig (cherry picked from commit df704bd38e77b1cea53d6396e03198cd58f8ad51) Part-of: --- .pick_status.json | 2 +- src/intel/compiler/elk/elk_nir.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 9211c3e430e..9f5737aec87 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -4504,7 +4504,7 @@ "description": "elk: Call nir_opt_algebraic_late in elk_postprocess_nir", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "442daeb54a2e43bd450ebbb37fc05001f4acd08f", "notes": null diff --git a/src/intel/compiler/elk/elk_nir.c b/src/intel/compiler/elk/elk_nir.c index 7b4d8661205..6a8712a352c 100644 --- a/src/intel/compiler/elk/elk_nir.c +++ b/src/intel/compiler/elk/elk_nir.c @@ -1601,8 +1601,12 @@ elk_postprocess_nir(nir_shader *nir, const struct elk_compiler *compiler, }; OPT(nir_lower_subgroups, &subgroups_options); - if (OPT(nir_lower_int64)) + if (OPT(nir_lower_int64)) { elk_nir_optimize(nir, is_scalar, devinfo); + + /* elk_nir_optimize undoes late lowerings. */ + OPT(nir_opt_algebraic_late); + } } /* Do this only after the last opt_gcm. GCM will undo this lowering. */