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 <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41496>
This commit is contained in:
Caio Oliveira 2026-05-07 23:39:30 -07:00 committed by Marge Bot
parent 3850922b78
commit bb8d8a2141

View file

@ -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);
}