[Mesa-dev] [PATCH 13/20] i965/fs: Do not move MOVs writing the flag outside of control flow

Kenneth Graunke kenneth at whitecape.org
Tue Jul 18 00:17:03 UTC 2017


On Thursday, July 6, 2017 4:48:23 PM PDT Matt Turner wrote:
> The implementation of ballotARB() will start by zeroing the flags
> register. So, a doing something like
> 
>         if (gl_SubGroupInvocationARB % 2u == 0u) {
>                 ... = ballotARB(true);
> 		[...]
>         } else {
>                 ... = ballotARB(true);
> 		[...]
> 	}
> 
> (like fs-ballot-if-else.shader_test does) would generate identical MOVs
> to the same destination (the flag register!), and we definitely do not
> want to pull that out of the control flow.
> ---
>  src/intel/compiler/brw_fs_sel_peephole.cpp | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/intel/compiler/brw_fs_sel_peephole.cpp b/src/intel/compiler/brw_fs_sel_peephole.cpp
> index 8cd897f72e..fd02792beb 100644
> --- a/src/intel/compiler/brw_fs_sel_peephole.cpp
> +++ b/src/intel/compiler/brw_fs_sel_peephole.cpp
> @@ -68,7 +68,8 @@ count_movs_from_if(fs_inst *then_mov[MAX_MOVS], fs_inst *else_mov[MAX_MOVS],
>  {
>     int then_movs = 0;
>     foreach_inst_in_block(fs_inst, inst, then_block) {
> -      if (then_movs == MAX_MOVS || inst->opcode != BRW_OPCODE_MOV)
> +      if (then_movs == MAX_MOVS || inst->opcode != BRW_OPCODE_MOV ||
> +          inst->flags_written())
>           break;
>  
>        then_mov[then_movs] = inst;
> @@ -77,7 +78,8 @@ count_movs_from_if(fs_inst *then_mov[MAX_MOVS], fs_inst *else_mov[MAX_MOVS],
>  
>     int else_movs = 0;
>     foreach_inst_in_block(fs_inst, inst, else_block) {
> -      if (else_movs == MAX_MOVS || inst->opcode != BRW_OPCODE_MOV)
> +      if (else_movs == MAX_MOVS || inst->opcode != BRW_OPCODE_MOV ||
> +          inst->flags_written())
>           break;
>  
>        else_mov[else_movs] = inst;
> 

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170717/7c0d1ce8/attachment.sig>


More information about the mesa-dev mailing list