This will replace direct usage of nir_instrs_equal() in the CSE pass, which reduces an O(n^2) algorithm with an effectively O(n) one. It'll also be useful for implementing GVN on top of GCM.
v2:
- Add texture support.
- Add more comments.- Rename instr_can_hash() to instr_can_rewrite() since it's really more about whether its uses can be rewritten, and it's implicitly used by nir_instrs_equal() as well.
- Rename nir_instr_set_add() to nir_instr_set_add_or_rewrite() (Jason).
- Make the HASH() macro less magical (Topi).
- Rewrite the commit message.
v3:- For sorting phi sources, use a VLA, store pointers to the sources, and compare the predecessor pointer directly (Jason).
523a28d nir: add an instruction set API
src/glsl/nir/nir_instr_set.c | 314 ++++++++++++++++++++++++++++++++++++++++++
src/glsl/nir/nir_instr_set.h | 35 +++++
2 files changed, 349 insertions(+)
Upstream: cgit.freedesktop.org