mbox series

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

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

Message

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

Changes for v3:
  - Testing on non-x86 hosts with full-featured deposit ops showed
    some issues with some of the new computations of sign mask, which
    turn out to be a representational issue which leads to easy
    off-by-one errors.

    Change the representation of s_mask to include the sign itself
    not just repetitions.  Disable optimizations based on s_mask
    until the conversion is complete.

    Bitwise logical operations require no change.

    Extension, and sign-extending loads, now use INTn_MIN instead
    of MAKE_64BIT_MASK(n, 64 - n).

    The existing shift and the new deposit s_mask operations require
    no change, but that's only because they were buggy before.

Patches 6 and 49 are new.  Minor changes scattered in between.


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: Change representation of s_mask
  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: 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: 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: Re-enable sign-mask optimizations
  tcg/optimize: Move fold_bitsel_vec into alphabetic sort
  tcg/optimize: Move fold_cmp_vec, fold_cmpsel_vec into alphabetic sort

 tcg/optimize.c | 834 +++++++++++++++++++++++++------------------------
 1 file changed, 432 insertions(+), 402 deletions(-)