[Mesa-dev] MR: NIR: Partial redundancy elimination for compares

Ian Romanick idr at freedesktop.org
Mon Dec 17 22:04:51 UTC 2018


https://gitlab.freedesktop.org/mesa/mesa/merge_requests/22

This series adds a new optimization pass that tries to replace code
sequences like

if (x < y) {
    z = y - x;
    ...
}

with a sequence like

t = x - y;
if (t < 0) {
    z = -t;
    ...
}

On architectures where the subtract can generate the flags used by the
if-statement, this saves an instruction. It's also possible that moving
an instruction out of the if-statement will allow
nir_opt_peephole_select to convert the whole thing to a bcsel.

Currently only floating point compares and adds are supported. Adding
support for integer will be a challenge due to integer overflow. There
are a couple possible solutions, but they may not apply to all
architectures.



More information about the mesa-dev mailing list