extract and deposit_z are similar operations, only differing in that extract shifts the operand right and deposit_z shifts it left. However, their code generation is currently different.
extract is implemented as either SHL+SHR or SHR+AND, with the latter chosen for "simple" cases where we expect the immediate to be available or a zero extension instruction to be usable. deposit instead uses only AND+SHL, though SHL+SHR would be just as usable. To get the best of both worlds, introduce tcg_op_imm_match to check whether the processor supports the immediate that is needed for the mask, and if not fall back to two shifts. Paolo Paolo Bonzini (2): tcg: target-dependent lowering of extract to shr/and tcg: possibly convert deposit_z to shl+shr include/tcg/tcg.h | 2 ++ tcg/tcg-op.c | 58 +++++++++++++++++++++++++++++++---------------- tcg/tcg.c | 23 +++++++++++++++---- 3 files changed, 59 insertions(+), 24 deletions(-) -- 2.52.0
