From bb8d8a2141ef3f4ba95e2232890654eb42e897b5 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Thu, 7 May 2026 23:39:30 -0700 Subject: [PATCH] brw: Call size_read() once in regs_read() regs_read() itself gets inlined, but size_read() does not. In GCC release builds this results in three calls to size_read() at each site, one of them due to how MIN2 is expanded. Use a local variable to store the result. Below are fossil compilation times in a MTL machine compiling shaders for a BMG GPU: ``` // Differences at 95.0% confidence. // Rise of the Tomb Raider (n=20) -0.013 +/- 0.00596452 -2.56410256% +/- 1.15623% // Alan Wake (n=20) -0.1755 +/- 0.0144896 -5.29491628% +/- 0.425556% // Borderlands 3 (n=14) -0.562142857 +/- 0.129678 -3.84765816% +/- 0.870239% // Oblivion Remastered (n=14) -0.0821428571 +/- 0.0262485 -1.69867061% +/- 0.537247% // Baldur's Gate 3 (n=14) -1.61357143 +/- 0.21693 -3.69788342% +/- 0.486462% ``` Reviewed-by: Ian Romanick Part-of: --- src/intel/compiler/brw/brw_inst.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/intel/compiler/brw/brw_inst.h b/src/intel/compiler/brw/brw_inst.h index 12272db172f..11a017461ea 100644 --- a/src/intel/compiler/brw/brw_inst.h +++ b/src/intel/compiler/brw/brw_inst.h @@ -438,9 +438,9 @@ regs_read(const struct intel_device_info *devinfo, const brw_inst *inst, unsigne return 1; const unsigned reg_size = inst->src[i].file == UNIFORM ? 4 : REG_SIZE; + const unsigned size_read = inst->size_read(devinfo, i); return DIV_ROUND_UP(reg_offset(inst->src[i]) % reg_size + - inst->size_read(devinfo, i) - - MIN2(inst->size_read(devinfo, i), reg_padding(inst->src[i])), + size_read - MIN2(size_read, reg_padding(inst->src[i])), reg_size); }