add basic structure for selection IR optimization

Graphics / Beignet - Guo Yejun [intel.com] - 8 October 2015 03:25 UTC

The idea is that many optimzations can be done at selection IR level, which is nearly ISA-like *before* physical register allocation. The optimization here can help to reduce register use/spill.

It is hard to do the optimzation in late ASM stage since the ASM instructions are encoded without structured information in current implementation. It is also not good to move the optimization to early stage, we'll lose much optimization opportunity in early stage.

The idea expects that selection IR is almost ISA-like, trying to avoid optimization opportunity lose as far as possible. It means that we'd better do as much as possible at selection IR stage, instead of ASM generation stage. We can go in this direction in future development.

From implementation perspective, since the class gbe::Selection is already heavy, add new classes in new .cpp file to decouple them.

There are two levels of optimization, basic block level and global level. The peephole optimization such as local copy propagation can be done at basic block level, the dead code elimination can be done at global level. We can introduce more optimizations here.

The optimization can be controlled by env variable OCL_OPTIMIZE_SEL_IR

b1e7b7f add basic structure for selection IR optimization
backend/src/CMakeLists.txt | 1 +
backend/src/backend/gen_context.cpp | 3 +
backend/src/backend/gen_insn_selection.cpp | 1 +
backend/src/backend/gen_insn_selection.hpp | 5 ++
.../src/backend/gen_insn_selection_optimize.cpp | 67 ++++++++++++++++++++
5 files changed, 77 insertions(+)

Upstream: cgit.freedesktop.org


  • Share