nir: Implement optional b2f->iand lowering
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Wed, 2 May 2018 02:04:55 +0000 (02:04 +0000)
committerChristian Gmeiner <christian.gmeiner@gmail.com>
Fri, 18 May 2018 20:44:09 +0000 (22:44 +0200)
commit5d85a0a55b8c061fa6644ac24163542e3025834c
tree4238fcc08e99f410588f3dec7498d4e86ddc1e03
parent8ed2cabd04c4697802f4d275f839640826e462ee
nir: Implement optional b2f->iand lowering

This pass is required by the Midgard compiler; our instruction set uses
NIR-style booleans (~0 for true) but lacks a dedicated b2f instruction.
Normally, this lowering pass would be implemented in a backend-specific
algebraic pass, but this conflicts with the existing iand->b2f pass in
nir_opt_algebraic.py, hanging the compiler. This patch thus makes the
existing pass optional (default on -- all other backends should remain
unaffected), adding an optional pass for lowering the opposite
direction.

v2: Defer lowering until late algebraic optimisations to allow
optimising the b2f instruction itself.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
src/compiler/nir/nir.h
src/compiler/nir/nir_opt_algebraic.py