I don't think there's any reason we can't eliminate a dead instruction
when the writemask is zero.  I do wonder, though, why this patch
actually makes a difference.  There's an "if (!inst->dead_mask ||
!inst->dst.writemask)" three lines before the code visible in the patch
that makes it not kill the instruction if the writemask is zero.  I
don't remember why that's there, but if it weren't there, and the
writemask is zero, the dead_mask should also be zero, so it should be
handled by the "else if" block.

In short, I think that entire if/else if/else statement could use a look.

Bryan

On 10/07/2011 10:40 AM, Brian Paul wrote:
> From: Brian Paul <bri...@vmware.com>
>
> This fixes a bug where we'd wind up emitting an invalid instruction like
> MOVE R[0]., R[1];  - note the empty/zero writemask.  If we don't write to
> any dest register channels, cull the instruction.
> ---
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
> b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index d8ef8a3..44b1149 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -3776,8 +3776,14 @@ 
> glsl_to_tgsi_visitor::eliminate_dead_code_advanced(void)
>           iter.remove();
>           delete inst;
>           removed++;
> -      } else
> +      } else {
>           inst->dst.writemask &= ~(inst->dead_mask);
> +         if (inst->dst.writemask == 0) {
> +            iter.remove();
> +            delete inst;
> +            removed++;
> +         }
> +      }
>     }
>  
>     ralloc_free(write_level);
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to