mbox series

[00/46] tcg: Remove in-flight mask data from OptContext

Message ID 20241210152401.1823648-1-richard.henderson@linaro.org
Headers show
Series tcg: Remove in-flight mask data from OptContext | expand

Message

Richard Henderson Dec. 10, 2024, 3:23 p.m. UTC
The desire is to start re-using some of the fold_* functions
while lowering or simplifying operations during tcg_optmize.

Many of these fold_* functions set z_mask, s_mask, and a_mask,
which hang around until the end of the tcg_optmize loop and
are applied by finish_folding.  This disconnect between set
and apply is a problem -- we would no longer be applying the
masks to the correct opcode.

Fix this by making the masks local variables, passed down to
be applied immediately to the opcode being processed.


r~


Richard Henderson (46):
  tcg/optimize: Split out finish_bb, finish_ebb
  tcg/optimize: Copy mask writeback to fold_masks
  tcg/optimize: Add fold_masks_zsa, fold_masks_zs, fold_masks_z
  tcg/optimize: Use finish_folding in fold_add, fold_add_vec
  tcg/optimize: Use finish_folding in fold_addsub2
  tcg/optimize: Use fold_masks_zsa in fold_and
  tcg/optimize: Use fold_masks_zsa in fold_andc
  tcg/optimize: Use fold_masks_zs in fold_bswap
  tcg/optimize: Use fold_masks_z in fold_count_zeros
  tcg/optimize: Use fold_masks_z in fold_ctpop
  tcg/optimize: Use fold_and and fold_masks_z in fold_deposit
  tcg/optimize: Use finish_folding in fold_divide
  tcg/optimize: Use finish_folding in fold_dup, fold_dup2
  tcg/optimize: Use fold_masks_zs in fold_eqv
  tcg/optimize: Use fold_masks_zsa in fold_extract
  tcg/optimize: Use finish_folding in fold_extract2
  tcg/optimize: Use fold_masks_zsa in fold_exts
  tcg/optimize: Use fold_masks_zsa in fold_extu
  tcg/optimize: Use fold_masks_zs in fold_movcond
  tcg/optimize: Use finish_folding in fold_mul*
  tcg/optimize: Use fold_masks_zs in fold_nand
  tcg/optimize: Use fold_masks_z in fold_neg_no_const
  tcg/optimize: Use fold_masks_zs in fold_nor
  tcg/optimize: Use fold_masks_zs in fold_not
  tcg/optimize: Use fold_masks_zs in fold_or
  tcg/optimize: Use fold_masks_zs in fold_orc
  tcg/optimize: Use fold_masks_zs in fold_qemu_ld
  tcg/optimize: Return true from fold_qemu_st, fold_tcg_st
  tcg/optimize: Use finish_folding in fold_remainder
  tcg/optimize: Distinguish simplification in fold_setcond_zmask
  tcg/optimize: Use fold_masks_z in fold_setcond
  tcg/optimize: Use fold_masks_zs in fold_negsetcond
  tcg/optimize: Use fold_masks_z in fold_setcond2
  tcg/optimize: Use finish_folding in fold_cmp_vec
  tcg/optimize: Use finish_folding in fold_cmpsel_vec
  tcg/optimize: Use fold_masks_zsa in fold_sextract
  tcg/optimize: Use fold_masks_zs in fold_shift
  tcg/optimize: Use finish_folding in fold_sub, fold_sub_vec
  tcg/optimize: Use fold_masks_zs in fold_tcg_ld
  tcg/optimize: Use finish_folding in fold_tcg_ld_memcopy
  tcg/optimize: Use fold_masks_zs in fold_xor
  tcg/optimize: Use finish_folding in fold_bitsel_vec
  tcg/optimize: Use finish_folding as default in tcg_optimize
  tcg/optimize: Remove [zsa]_mask from OptContext
  tcg/optimize: Move fold_bitsel_vec into alphabetic sort
  tcg/optimize: Move fold_cmp_vec, fold_cmpsel_vec into alphabetic sort

 tcg/optimize.c | 597 ++++++++++++++++++++++++++-----------------------
 1 file changed, 315 insertions(+), 282 deletions(-)

Comments

Richard Henderson Dec. 16, 2024, 2:15 p.m. UTC | #1
Ping.

On 12/10/24 09:23, Richard Henderson wrote:
> The desire is to start re-using some of the fold_* functions
> while lowering or simplifying operations during tcg_optmize.
> 
> Many of these fold_* functions set z_mask, s_mask, and a_mask,
> which hang around until the end of the tcg_optimize loop and
> are applied by finish_folding.  This disconnect between set
> and apply is a problem -- we would no longer be applying the
> masks to the correct opcode.
> 
> Fix this by making the masks local variables, passed down to
> be applied immediately to the opcode being processed.
> 
> 
> r~
> 
> 
> Richard Henderson (46):
>    tcg/optimize: Split out finish_bb, finish_ebb
>    tcg/optimize: Copy mask writeback to fold_masks
>    tcg/optimize: Add fold_masks_zsa, fold_masks_zs, fold_masks_z
>    tcg/optimize: Use finish_folding in fold_add, fold_add_vec
>    tcg/optimize: Use finish_folding in fold_addsub2
>    tcg/optimize: Use fold_masks_zsa in fold_and
>    tcg/optimize: Use fold_masks_zsa in fold_andc
>    tcg/optimize: Use fold_masks_zs in fold_bswap
>    tcg/optimize: Use fold_masks_z in fold_count_zeros
>    tcg/optimize: Use fold_masks_z in fold_ctpop
>    tcg/optimize: Use fold_and and fold_masks_z in fold_deposit
>    tcg/optimize: Use finish_folding in fold_divide
>    tcg/optimize: Use finish_folding in fold_dup, fold_dup2
>    tcg/optimize: Use fold_masks_zs in fold_eqv
>    tcg/optimize: Use fold_masks_zsa in fold_extract
>    tcg/optimize: Use finish_folding in fold_extract2
>    tcg/optimize: Use fold_masks_zsa in fold_exts
>    tcg/optimize: Use fold_masks_zsa in fold_extu
>    tcg/optimize: Use fold_masks_zs in fold_movcond
>    tcg/optimize: Use finish_folding in fold_mul*
>    tcg/optimize: Use fold_masks_zs in fold_nand
>    tcg/optimize: Use fold_masks_z in fold_neg_no_const
>    tcg/optimize: Use fold_masks_zs in fold_nor
>    tcg/optimize: Use fold_masks_zs in fold_not
>    tcg/optimize: Use fold_masks_zs in fold_or
>    tcg/optimize: Use fold_masks_zs in fold_orc
>    tcg/optimize: Use fold_masks_zs in fold_qemu_ld
>    tcg/optimize: Return true from fold_qemu_st, fold_tcg_st
>    tcg/optimize: Use finish_folding in fold_remainder
>    tcg/optimize: Distinguish simplification in fold_setcond_zmask
>    tcg/optimize: Use fold_masks_z in fold_setcond
>    tcg/optimize: Use fold_masks_zs in fold_negsetcond
>    tcg/optimize: Use fold_masks_z in fold_setcond2
>    tcg/optimize: Use finish_folding in fold_cmp_vec
>    tcg/optimize: Use finish_folding in fold_cmpsel_vec
>    tcg/optimize: Use fold_masks_zsa in fold_sextract
>    tcg/optimize: Use fold_masks_zs in fold_shift
>    tcg/optimize: Use finish_folding in fold_sub, fold_sub_vec
>    tcg/optimize: Use fold_masks_zs in fold_tcg_ld
>    tcg/optimize: Use finish_folding in fold_tcg_ld_memcopy
>    tcg/optimize: Use fold_masks_zs in fold_xor
>    tcg/optimize: Use finish_folding in fold_bitsel_vec
>    tcg/optimize: Use finish_folding as default in tcg_optimize
>    tcg/optimize: Remove [zsa]_mask from OptContext
>    tcg/optimize: Move fold_bitsel_vec into alphabetic sort
>    tcg/optimize: Move fold_cmp_vec, fold_cmpsel_vec into alphabetic sort
> 
>   tcg/optimize.c | 597 ++++++++++++++++++++++++++-----------------------
>   1 file changed, 315 insertions(+), 282 deletions(-)
>
Pierrick Bouvier Dec. 17, 2024, 1:39 a.m. UTC | #2
On 12/16/24 06:15, Richard Henderson wrote:
> Ping.
> 

I'll take a look tomorrow morning.

Pierrick

> On 12/10/24 09:23, Richard Henderson wrote:
>> The desire is to start re-using some of the fold_* functions
>> while lowering or simplifying operations during tcg_optmize.
>>
>> Many of these fold_* functions set z_mask, s_mask, and a_mask,
>> which hang around until the end of the tcg_optimize loop and
>> are applied by finish_folding.  This disconnect between set
>> and apply is a problem -- we would no longer be applying the
>> masks to the correct opcode.
>>
>> Fix this by making the masks local variables, passed down to
>> be applied immediately to the opcode being processed.
>>
>>
>> r~
>>
>>
>> Richard Henderson (46):
>>     tcg/optimize: Split out finish_bb, finish_ebb
>>     tcg/optimize: Copy mask writeback to fold_masks
>>     tcg/optimize: Add fold_masks_zsa, fold_masks_zs, fold_masks_z
>>     tcg/optimize: Use finish_folding in fold_add, fold_add_vec
>>     tcg/optimize: Use finish_folding in fold_addsub2
>>     tcg/optimize: Use fold_masks_zsa in fold_and
>>     tcg/optimize: Use fold_masks_zsa in fold_andc
>>     tcg/optimize: Use fold_masks_zs in fold_bswap
>>     tcg/optimize: Use fold_masks_z in fold_count_zeros
>>     tcg/optimize: Use fold_masks_z in fold_ctpop
>>     tcg/optimize: Use fold_and and fold_masks_z in fold_deposit
>>     tcg/optimize: Use finish_folding in fold_divide
>>     tcg/optimize: Use finish_folding in fold_dup, fold_dup2
>>     tcg/optimize: Use fold_masks_zs in fold_eqv
>>     tcg/optimize: Use fold_masks_zsa in fold_extract
>>     tcg/optimize: Use finish_folding in fold_extract2
>>     tcg/optimize: Use fold_masks_zsa in fold_exts
>>     tcg/optimize: Use fold_masks_zsa in fold_extu
>>     tcg/optimize: Use fold_masks_zs in fold_movcond
>>     tcg/optimize: Use finish_folding in fold_mul*
>>     tcg/optimize: Use fold_masks_zs in fold_nand
>>     tcg/optimize: Use fold_masks_z in fold_neg_no_const
>>     tcg/optimize: Use fold_masks_zs in fold_nor
>>     tcg/optimize: Use fold_masks_zs in fold_not
>>     tcg/optimize: Use fold_masks_zs in fold_or
>>     tcg/optimize: Use fold_masks_zs in fold_orc
>>     tcg/optimize: Use fold_masks_zs in fold_qemu_ld
>>     tcg/optimize: Return true from fold_qemu_st, fold_tcg_st
>>     tcg/optimize: Use finish_folding in fold_remainder
>>     tcg/optimize: Distinguish simplification in fold_setcond_zmask
>>     tcg/optimize: Use fold_masks_z in fold_setcond
>>     tcg/optimize: Use fold_masks_zs in fold_negsetcond
>>     tcg/optimize: Use fold_masks_z in fold_setcond2
>>     tcg/optimize: Use finish_folding in fold_cmp_vec
>>     tcg/optimize: Use finish_folding in fold_cmpsel_vec
>>     tcg/optimize: Use fold_masks_zsa in fold_sextract
>>     tcg/optimize: Use fold_masks_zs in fold_shift
>>     tcg/optimize: Use finish_folding in fold_sub, fold_sub_vec
>>     tcg/optimize: Use fold_masks_zs in fold_tcg_ld
>>     tcg/optimize: Use finish_folding in fold_tcg_ld_memcopy
>>     tcg/optimize: Use fold_masks_zs in fold_xor
>>     tcg/optimize: Use finish_folding in fold_bitsel_vec
>>     tcg/optimize: Use finish_folding as default in tcg_optimize
>>     tcg/optimize: Remove [zsa]_mask from OptContext
>>     tcg/optimize: Move fold_bitsel_vec into alphabetic sort
>>     tcg/optimize: Move fold_cmp_vec, fold_cmpsel_vec into alphabetic sort
>>
>>    tcg/optimize.c | 597 ++++++++++++++++++++++++++-----------------------
>>    1 file changed, 315 insertions(+), 282 deletions(-)
>>
>
Pierrick Bouvier Dec. 17, 2024, 8:11 p.m. UTC | #3
On 12/10/24 07:23, Richard Henderson wrote:
> The desire is to start re-using some of the fold_* functions
> while lowering or simplifying operations during tcg_optmize.
> 
> Many of these fold_* functions set z_mask, s_mask, and a_mask,
> which hang around until the end of the tcg_optmize loop and
> are applied by finish_folding.  This disconnect between set
> and apply is a problem -- we would no longer be applying the
> masks to the correct opcode.
> 

A general question on this:

Where do the s_ (sign?) and a_ (?) names comes from?
Reading the description of those struct members, I can't really connect 
to their names, except for z_mask.

> Fix this by making the masks local variables, passed down to
> be applied immediately to the opcode being processed.
> 
> 
> r~
> 
> 
> Richard Henderson (46):
>    tcg/optimize: Split out finish_bb, finish_ebb
>    tcg/optimize: Copy mask writeback to fold_masks
>    tcg/optimize: Add fold_masks_zsa, fold_masks_zs, fold_masks_z
>    tcg/optimize: Use finish_folding in fold_add, fold_add_vec
>    tcg/optimize: Use finish_folding in fold_addsub2
>    tcg/optimize: Use fold_masks_zsa in fold_and
>    tcg/optimize: Use fold_masks_zsa in fold_andc
>    tcg/optimize: Use fold_masks_zs in fold_bswap
>    tcg/optimize: Use fold_masks_z in fold_count_zeros
>    tcg/optimize: Use fold_masks_z in fold_ctpop
>    tcg/optimize: Use fold_and and fold_masks_z in fold_deposit
>    tcg/optimize: Use finish_folding in fold_divide
>    tcg/optimize: Use finish_folding in fold_dup, fold_dup2
>    tcg/optimize: Use fold_masks_zs in fold_eqv
>    tcg/optimize: Use fold_masks_zsa in fold_extract
>    tcg/optimize: Use finish_folding in fold_extract2
>    tcg/optimize: Use fold_masks_zsa in fold_exts
>    tcg/optimize: Use fold_masks_zsa in fold_extu
>    tcg/optimize: Use fold_masks_zs in fold_movcond
>    tcg/optimize: Use finish_folding in fold_mul*
>    tcg/optimize: Use fold_masks_zs in fold_nand
>    tcg/optimize: Use fold_masks_z in fold_neg_no_const
>    tcg/optimize: Use fold_masks_zs in fold_nor
>    tcg/optimize: Use fold_masks_zs in fold_not
>    tcg/optimize: Use fold_masks_zs in fold_or
>    tcg/optimize: Use fold_masks_zs in fold_orc
>    tcg/optimize: Use fold_masks_zs in fold_qemu_ld
>    tcg/optimize: Return true from fold_qemu_st, fold_tcg_st
>    tcg/optimize: Use finish_folding in fold_remainder
>    tcg/optimize: Distinguish simplification in fold_setcond_zmask
>    tcg/optimize: Use fold_masks_z in fold_setcond
>    tcg/optimize: Use fold_masks_zs in fold_negsetcond
>    tcg/optimize: Use fold_masks_z in fold_setcond2
>    tcg/optimize: Use finish_folding in fold_cmp_vec
>    tcg/optimize: Use finish_folding in fold_cmpsel_vec
>    tcg/optimize: Use fold_masks_zsa in fold_sextract
>    tcg/optimize: Use fold_masks_zs in fold_shift
>    tcg/optimize: Use finish_folding in fold_sub, fold_sub_vec
>    tcg/optimize: Use fold_masks_zs in fold_tcg_ld
>    tcg/optimize: Use finish_folding in fold_tcg_ld_memcopy
>    tcg/optimize: Use fold_masks_zs in fold_xor
>    tcg/optimize: Use finish_folding in fold_bitsel_vec
>    tcg/optimize: Use finish_folding as default in tcg_optimize
>    tcg/optimize: Remove [zsa]_mask from OptContext
>    tcg/optimize: Move fold_bitsel_vec into alphabetic sort
>    tcg/optimize: Move fold_cmp_vec, fold_cmpsel_vec into alphabetic sort
> 
>   tcg/optimize.c | 597 ++++++++++++++++++++++++++-----------------------
>   1 file changed, 315 insertions(+), 282 deletions(-)
>