[Mesa-dev] [PATCH 05/15] i965/fs: Don't dead code eliminate CMP(N).

Eric Anholt eric at anholt.net
Tue Oct 29 07:08:04 CET 2013


Matt Turner <mattst88 at gmail.com> writes:

> Since compare instructions write the flag register, they should not be
> considered dead even if their destination is never read. Instead of
> removing them if found to be dead, set their destination to null to free
> a register.
>
> ---
>  src/mesa/drivers/dri/i965/brw_fs.cpp | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index 7e7ced0..b985251 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -1903,10 +1903,12 @@ fs_visitor::dead_code_eliminate()
>  
>           if (dead) {
>              /* Don't dead code eliminate instructions that write to the
> -             * accumulator as a side-effect. Instead just set the destination
> -             * to the null register to free it.
> +             * accumulator or flag register as a side effect. Instead just set
> +             * the destination to the null register to free it.
>               */
>              switch (inst->opcode) {
> +            case BRW_OPCODE_CMP:
> +            case BRW_OPCODE_CMPN:
>              case BRW_OPCODE_ADDC:
>              case BRW_OPCODE_SUBB:
>              case BRW_OPCODE_MACH:

I don't think this one is needed in the series any more after the rework
to not generate new CMP.whatever.f0 to a non-null destination in CSE,
but I think it should still land anyway.  I'd prefer the test for
"writes to the flag register" to be inst->writes_flag() rather than just
a couple of opcodes that always write the flag, though.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20131028/fdf58d5a/attachment.pgp>


More information about the mesa-dev mailing list