[Mesa-dev] [PATCH] nir: Implement optional b2f->iand lowering
Matt Turner
mattst88 at gmail.com
Mon Apr 30 21:08:47 UTC 2018
On Sun, Apr 29, 2018 at 11:19 AM, Alyssa Rosenzweig
<alyssa at rosenzweig.io> wrote:
> 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.
Tell me a little more about what your hardware supports. Does it have
real integers?
In the i965 driver, we used to do what you suggest (AND with
0x3f800000), but changed to a type converting MOV with a source
modifier: MOV dest:F, -src0:D since we could occasionally optimize
that instruction away. That is, interpret the source as an integer (so
false is 0 and true is -1), negate it, and convert to a float.
We did both of these things in our backend when translating NIR's b2f
into our backend IR. Why is it better for you to do that in NIR?
More information about the mesa-dev
mailing list