nir: add conditional discard optimisation (v4)
authorDave Airlie <airlied@redhat.com>
Wed, 2 Nov 2016 01:22:07 +0000 (01:22 +0000)
committerDave Airlie <airlied@redhat.com>
Wed, 9 Nov 2016 19:46:33 +0000 (05:46 +1000)
commitb16dff2d88302e5113598a818d2f92f8af02cd79
treece7db783f52eb317f4a7ffea690e51c4a6c31a1c
parentdd77faeca2819fc78a72f71ca9b996c209378cde
nir: add conditional discard optimisation (v4)

This is ported from GLSL and converts

if (cond)
discard;

into
discard_if(cond);

This removes a block, but also is needed by radv
to workaround a bug in the LLVM backend.

v2: handle if (a) discard_if(b) (nha)
cleanup and drop pointless loop (Matt)
make sure there are no dependent phis (Eric)
v3: make sure only one instruction in the then block.
v4: remove sneaky tabs, add cursor init (Eric)

Reviewed-by: Eric Anholt <eric@anholt.net>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/compiler/Makefile.sources
src/compiler/nir/nir.h
src/compiler/nir/nir_opt_conditional_discard.c [new file with mode: 0644]