[PATCH v2 00/27] tcg/optimize: Track and use known 1's

Richard Henderson posted 27 patches 5 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250603080908.559594-1-richard.henderson@linaro.org
Maintainers: Richard Henderson <richard.henderson@linaro.org>
tcg/optimize.c | 456 +++++++++++++++++++++++++++++--------------------
1 file changed, 274 insertions(+), 182 deletions(-)
[PATCH v2 00/27] tcg/optimize: Track and use known 1's
Posted by Richard Henderson 5 months, 2 weeks ago
We already track and use known 0's; do the same for 1's.
This actually simplifies some of the logical operations,
where before required checking for a constant value.

Changes for v2:
  - Some simplifications suggested by Paolo.

  - Merge affected bit handling into fold_masks_zosa.
    There's an optimization ordering preference for
      1) constant result
      2) copy result
      3) computed result
    Having fold_affected_mask separate performed 2 before 1.

  - Rearrange the and->extract optimization, because it
    would perform 3 before 1 and 2.


r~


Richard Henderson (27):
  tcg/optimize: Introduce arg_const_val
  tcg/optimize: Add one's mask to TempOptInfo
  tcg/optimize: Introduce fold_masks_zosa
  tcg/optimize: Build and use o_bits in fold_and
  tcg/optimize: Build and use o_bits in fold_andc
  tcg/optimize: Build and use z_bits and o_bits in fold_eqv
  tcg/optimize: Build and use z_bits and o_bits in fold_nand
  tcg/optimize: Build and use z_bits and o_bits in fold_nor
  tcg/optimize: Build and use z_bits and o_bits in fold_not
  tcg/optimize: Build and use one and affected bits in fold_or
  tcg/optimize: Build and use zero, one and affected bits in fold_orc
  tcg/optimize: Build and use o_bits in fold_xor
  tcg/optimize: Build and use o_bits in fold_bswap
  tcg/optimize: Build and use o_bits in fold_deposit
  tcg/optimize: Build and use o_bits in fold_extract
  tcg/optimize: Build and use z_bits and o_bits in fold_extract2
  tcg/optimize: Build and use o_bits in fold_exts
  tcg/optimize: Build and use o_bits in fold_extu
  tcg/optimize: Build and use o_bits in fold_movcond
  tcg/optimize: Build and use o_bits in fold_sextract
  tcg/optimize: Build and use o_bits in fold_shift
  tcg/optimize: Use fold_and in do_constant_folding_cond[12]
  tcg/optimize: Fold and to extract during optimize
  tcg/optimize: Simplify fold_and constant checks
  tcg/optimize: Simplify fold_andc constant checks
  tcg/optimize: Simplify fold_orc constant checks
  tcg/optimize: Simplify fold_eqv constant checks

 tcg/optimize.c | 456 +++++++++++++++++++++++++++++--------------------
 1 file changed, 274 insertions(+), 182 deletions(-)

-- 
2.43.0
Re: [PATCH v2 00/27] tcg/optimize: Track and use known 1's
Posted by Richard Henderson 4 months, 3 weeks ago
Ping.

On 6/3/25 01:08, Richard Henderson wrote:
> We already track and use known 0's; do the same for 1's.
> This actually simplifies some of the logical operations,
> where before required checking for a constant value.
> 
> Changes for v2:
>    - Some simplifications suggested by Paolo.
> 
>    - Merge affected bit handling into fold_masks_zosa.
>      There's an optimization ordering preference for
>        1) constant result
>        2) copy result
>        3) computed result
>      Having fold_affected_mask separate performed 2 before 1.
> 
>    - Rearrange the and->extract optimization, because it
>      would perform 3 before 1 and 2.
> 
> 
> r~
> 
> 
> Richard Henderson (27):
>    tcg/optimize: Introduce arg_const_val
>    tcg/optimize: Add one's mask to TempOptInfo
>    tcg/optimize: Introduce fold_masks_zosa
>    tcg/optimize: Build and use o_bits in fold_and
>    tcg/optimize: Build and use o_bits in fold_andc
>    tcg/optimize: Build and use z_bits and o_bits in fold_eqv
>    tcg/optimize: Build and use z_bits and o_bits in fold_nand
>    tcg/optimize: Build and use z_bits and o_bits in fold_nor
>    tcg/optimize: Build and use z_bits and o_bits in fold_not
>    tcg/optimize: Build and use one and affected bits in fold_or
>    tcg/optimize: Build and use zero, one and affected bits in fold_orc
>    tcg/optimize: Build and use o_bits in fold_xor
>    tcg/optimize: Build and use o_bits in fold_bswap
>    tcg/optimize: Build and use o_bits in fold_deposit
>    tcg/optimize: Build and use o_bits in fold_extract
>    tcg/optimize: Build and use z_bits and o_bits in fold_extract2
>    tcg/optimize: Build and use o_bits in fold_exts
>    tcg/optimize: Build and use o_bits in fold_extu
>    tcg/optimize: Build and use o_bits in fold_movcond
>    tcg/optimize: Build and use o_bits in fold_sextract
>    tcg/optimize: Build and use o_bits in fold_shift
>    tcg/optimize: Use fold_and in do_constant_folding_cond[12]
>    tcg/optimize: Fold and to extract during optimize
>    tcg/optimize: Simplify fold_and constant checks
>    tcg/optimize: Simplify fold_andc constant checks
>    tcg/optimize: Simplify fold_orc constant checks
>    tcg/optimize: Simplify fold_eqv constant checks
> 
>   tcg/optimize.c | 456 +++++++++++++++++++++++++++++--------------------
>   1 file changed, 274 insertions(+), 182 deletions(-)
>