Reverse LUT for LOP3.LUT

Is there a reference table anywhere, where one can take the LUT value from a SASS dumped LOP3.LUT instruction and see what the actual logic ops are?


Any number of different sequences of logic operations can map to the same truth table, i.e. this is a many-to-one mapping, not a bijection. Therefore one cannot unambiguously map a truth-table value back to a particular sequence of logic operations.

But one can certainly set up a logic equation corresponding to a LOP3.LUT truth table (see code below) and then transform that into any particular form (e.g. DNF, CNF, NAND) desired.

/* emulate GPU's LOP3.LUT (three-input logic op with 8-bit truth table) */
uint32_t lop3_fast (uint32_t a, uint32_t b, uint32_t c, uint8_t ttbl)
    uint32_t r = 0;
    if (ttbl & 0x01) r |= ~a & ~b & ~c;
    if (ttbl & 0x02) r |= ~a & ~b &  c;
    if (ttbl & 0x04) r |= ~a &  b & ~c;
    if (ttbl & 0x08) r |= ~a &  b &  c;
    if (ttbl & 0x10) r |=  a & ~b & ~c;
    if (ttbl & 0x20) r |=  a & ~b &  c;
    if (ttbl & 0x40) r |=  a &  b & ~c;
    if (ttbl & 0x80) r |=  a &  b &  c;
    return r;

Thanks, I should have seen that, (the many to one).

I’m trying to optimise and the LOP3’s are making things somewhat opaque.