nir/algebraic: add lowering for fsign
authorErico Nunes <nunes.erico@gmail.com>
Tue, 16 Apr 2019 20:49:41 +0000 (22:49 +0200)
committerEric Anholt <eric@anholt.net>
Fri, 19 Apr 2019 15:42:23 +0000 (15:42 +0000)
commit4577eb7b7cddb0a5dd2ee77682eab01a4d55676b
treee78a233f7f588e52eb8f59dc766e1c8990151693
parentf9c594cdf5a69aabe2dfb8e6f61224cc2ff7b149
nir/algebraic: add lowering for fsign

The mali utgard pp doesn't support a sign instruction.
In the ARM offline shader compiler, the sign function is implemented
using sub(gt(0.0, a), lt(0.0, a)).
This is a generic optimization, so implement it in the nir level when
lower_fsign is set, alongside the lowering for isign.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/compiler/nir/nir.h
src/compiler/nir/nir_opt_algebraic.py