i965/fs: Generate better code for ir_triop_csel.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 16 Oct 2014 01:57:07 +0000 (18:57 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 22 Oct 2014 04:13:37 +0000 (21:13 -0700)
commit4d34c4b5823de984fb8f0469b67c6b4be02030b2
treec13d3d48970d99c286949b7b1c303da18ecee64e
parent32364a1fe58a09914daf4eef96674969167665d7
i965/fs: Generate better code for ir_triop_csel.

Previously, we generated an extra CMP instruction:

   cmp.ge.f0(8)   g4<1>D          g2<0,1,0>F      0F
   cmp.nz.f0(8)   null            g4<8,8,1>D      0D
   (+f0) sel(8)   g120<1>F        g2.4<0,1,0>F    g3<0,1,0>F

The first operand is always a boolean, and we want to predicate the SEL
on that.  Rather than producing a boolean value and comparing it against
zero, we can just produce a condition code in the flag register.

Now we generate:

   cmp.ge.f0(8)    null            g2<0,1,0>F      0F
   (+f0) sel(8)    g124<1>F        g2.4<0,1,0>F    g3<0,1,0>F

total instructions in shared programs: 5473459 -> 5473253 (-0.00%)
instructions in affected programs:     6219 -> 6013 (-3.31%)

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp