mbox series

[v2,00/51] tcg: Remove in-flight mask data from OptContext

Message ID 20241220041104.53105-1-richard.henderson@linaro.org (mailing list archive)
Headers show
Series tcg: Remove in-flight mask data from OptContext | expand

Message

Richard Henderson Dec. 20, 2024, 4:10 a.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.

Changes for v2:
  - Introduce fold_affected_mask, to handle a_mask separately from both
    z_mask and s_mask.  There are only a couple of places where we can
    compute a_mask, and handling that separately simplifies some things.
    This means that fold_masks_zsa is gone, and fold_masks_za need not
    be created.

  - Introduce fold_masks_s, as suggested in review.

  - In many places, fetch the TempOptInfo pointers once.  This doesn't
    affect the resulting optimized code, but it's easier to read.

  - There are a couple of logic fixes, separated out to new patches.
  - There are a couple of logic improvements for fold_count_zero
    and fold_deposit.

Patches lacking review:
  02-tcg-optimize-Split-out-fold_affected_mask.patch
  04-tcg-optimize-Split-out-fold_masks_zs.patch
  05-tcg-optimize-Augment-s_mask-from-z_mask-in-fold_m.patch
  10-tcg-optimize-Use-fold_masks_zs-in-fold_count_zero.patch
  13-tcg-optimize-Compute-sign-mask-in-fold_deposit.patch
  29-tcg-optimize-Use-fold_masks_zs-in-fold_qemu_ld.patch
  35-tcg-optimize-Fix-sign-mask-in-fold_negsetcond.patch
  40-tcg-optimize-Canonicalize-s_mask-in-fold_exts-fol.patch
  42-tcg-optimize-Simplify-sign-bit-test-in-fold_shift.patch


r~


Richard Henderson (51):
  tcg/optimize: Split out finish_bb, finish_ebb
  tcg/optimize: Split out fold_affected_mask
  tcg/optimize: Copy mask writeback to fold_masks
  tcg/optimize: Split out fold_masks_zs
  tcg/optimize: Augment s_mask from z_mask in fold_masks_zs
  tcg/optimize: Use finish_folding in fold_add, fold_add_vec,
    fold_addsub2
  tcg/optimize: Use fold_masks_zs in fold_and
  tcg/optimize: Use fold_masks_zs in fold_andc
  tcg/optimize: Use fold_masks_zs in fold_bswap
  tcg/optimize: Use fold_masks_zs 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: Compute sign mask 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_s in fold_eqv
  tcg/optimize: Use fold_masks_z in fold_extract
  tcg/optimize: Use finish_folding in fold_extract2
  tcg/optimize: Use fold_masks_zs in fold_exts
  tcg/optimize: Use fold_masks_z 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_s in fold_nand
  tcg/optimize: Use fold_masks_z in fold_neg_no_const
  tcg/optimize: Use fold_masks_s in fold_nor
  tcg/optimize: Use fold_masks_s 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_s in fold_negsetcond
  tcg/optimize: Fix sign mask 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_zs in fold_sextract
  tcg/optimize: Canonicalize s_mask in fold_exts, fold_sextract
  tcg/optimize: Use fold_masks_zs, fold_masks_s in fold_shift
  tcg/optimize: Simplify sign bit test 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 z_mask, s_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 | 776 +++++++++++++++++++++++++++----------------------
 1 file changed, 425 insertions(+), 351 deletions(-)