[Mesa-dev] [PATCH 1/2] nir: Add inverted bitwise ops

Alyssa Rosenzweig alyssa at rosenzweig.io
Fri Apr 26 02:30:41 UTC 2019


> iand and ior are commutative, so you don't need both.

--Wait, woaaah, the algebraic generator respects that? Super neat, thank
you!

> Especially without instruction count data

(I'm assuming I won't be able to do shader-db on my hw at this point..)

> For example, if the only use of inot(...some logic...) is an
> if-condition, we don't want to re-write it.  Our backend will just
> invert the "polarity" of the conditional branch. 

Out of curiousity, what's the specific issue? Midgard also specifies
branch polarity, though I currently hardcode to true since I'm not
convinced it makes a difference.

> My gut tells me that doing this in
> the backend with something like Eric's NOLTIS is the right way to go.

I'm not sure what NOLTIS is, sorry.

Would you ack a change adding the ops to nir_opcode.py but not adding an
opt passes? I have a backend algebra pass which I'm happy to move this
into (and I think it would be a win on Midgard regardless); I just
(AFAIK) need the ops in NIR for the algebra pass to work at all. [I
don't want to duplicate this infrastructure to run over the machine IR,
which is quite limited since I trust the input NIR to be good.]

Thank you for the comments.

> This is also part of the reason that I've never sent out some other
> patches that I have that convert certain kinds of logic operations into
> other things.  For example,
> 
>    # True iff a == -1 and b == 0
>    (('iand', 'a at bool32', ('inot', 'b at bool32)), ('ilt', a, b)),

...Cute. Point taken :)


More information about the mesa-dev mailing list