[Mesa-dev] [PATCH 0/6] nir: Implement a load-combine pass

Eduardo Lima Mitev elima at igalia.com
Thu Apr 14 16:52:30 UTC 2016


This is a series adding a new NIR pass that will combine redundant SSBO, shared variable and image load instructions. It is based on a previous series that Iago Toral [1] sent a few months ago, which I have updated to account for changes in NIR since then, and also added support for shared variables and image load/store.

Currently, the emitted load instructions for these types of variables are highly redundant. For example, assuming 'value' is an SSBO float, doing:

float next = value + 1.0;
float prev = value - 1.0;

will generate two redundant load_ssbo instructions. The extreme case of this is:

mat4 mult = ssbo_mat4 * ssbo_mat4;

which will spwan 16 load_ssbo instructions.

Compute shader's shared variables and image loads (from ARB_image_load_store) suffer from the same problem. This pass coaleses the redundant loads, and is also able to combine a load with a previous store to the same address.

I'm still working on a piglit test series that tied up the different corner cases, but it doesn't hurt to get a few eyes on this already. The WIP piglit branch is at: https://github.com/Igalia/piglit/commits/nir-opt-load-combine-rc1
You can see there a test example for the matrix multiplication cases: https://github.com/Igalia/piglit/commit/b7ea6d2553891c7eec993c39352a10925ebcefbc. This pass is able to reduce the emitted instructions from 210 to 134 (~64%), comparing to Mesa master.

No piglit or dEQP-GLES31 regressions observed.


[1] https://lists.freedesktop.org/archives/mesa-dev/2015-October/098426.html

Eduardo Lima Mitev (3):
  nir/opt_load_combine: Extend the pass to include shared variables
  nir/opt_load_combine: Extend the pass to include image load/store

Iago Toral (3):
  nir: add a load-combine pass
  nir/load_combine: expand the pass to support load-after-store
  i965: use the load-combine pass

 src/compiler/Makefile.sources           |   1 +
 src/compiler/nir/nir.h                  |   2 +
 src/compiler/nir/nir_opt_load_combine.c | 807 ++++++++++++++++++++++++++++++++
 src/mesa/drivers/dri/i965/brw_nir.c     |   1 +
 4 files changed, 811 insertions(+)
 create mode 100644 src/compiler/nir/nir_opt_load_combine.c


More information about the mesa-dev mailing list