On Sun, Sep 27, 2026 at 5:00 AM Richard Henderson
<[email protected]> wrote:
>
> Signed-off-by: Richard Henderson <[email protected]>
> ---
> include/tcg/tcg-op-common.h | 2 --
> include/tcg/tcg-op-def.h.inc | 1 +
> tcg/tcg-op.c | 15 +++++----------
> 3 files changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h
> index 8444044ed57..ff15e3b88ae 100644
> --- a/include/tcg/tcg-op-common.h
> +++ b/include/tcg/tcg-op-common.h
> @@ -124,7 +124,6 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned
> meminfo);
> /* 32 bit ops */
>
> void tcg_gen_subfi_i32(TCGv_i32 ret, int32_t arg1, TCGv_i32 arg2);
> -void tcg_gen_subi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2);
> void tcg_gen_andi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2);
> void tcg_gen_ori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2);
> void tcg_gen_xori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2);
> @@ -225,7 +224,6 @@ void tcg_gen_not_i32(TCGv_i32 ret, TCGv_i32 arg);
> /* 64 bit ops */
>
> void tcg_gen_subfi_i64(TCGv_i64 ret, int64_t arg1, TCGv_i64 arg2);
> -void tcg_gen_subi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2);
> void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2);
> void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2);
> void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2);
> diff --git a/include/tcg/tcg-op-def.h.inc b/include/tcg/tcg-op-def.h.inc
> index 51d5ec6e06a..55249c4dd6f 100644
> --- a/include/tcg/tcg-op-def.h.inc
> +++ b/include/tcg/tcg-op-def.h.inc
> @@ -7,3 +7,4 @@ DEF1(discard, TCGV)
> DEF2(mov, TCGV, TCGV)
> DEF2(movi, TCGV, TINT)
> DEF3(sub, TCGV, TCGV, TCGV)
> +DEF3(subi, TCGV, TCGV, TINT)
> diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
> index 2865de65d39..9bcf79ccbfc 100644
> --- a/tcg/tcg-op.c
> +++ b/tcg/tcg-op.c
> @@ -399,6 +399,11 @@ void tcg_gen_sub(TCGType type, TCGTemp *dst, TCGTemp
> *src1, TCGTemp *src2)
> tcg_gen_op_ttt(INDEX_op_sub, type, dst, src1, src2);
> }
>
> +void tcg_gen_subi(TCGType type, TCGTemp *dst, TCGTemp *src1, int64_t src2)
> +{
> + tcg_gen_addi(type, dst, src1, -src2);
Double check me on this, but since src2's type changed from int32_t to
int64_t, I think this will produce a value that isn't sign-extended
for I32.
E.g. for I32 with src2 == INT32_MIN this now produces 0x80000000
rather than the 0xffffffff80000000 the old code produced.
tcg_constant_internal() doesn't canonicalize, so we end up with an I32
constant that isn't sign-extended, which optimize.c assumes can't
happen.
Going to make a quick sweep over the rest of the series to look for
this issue specifically.
> +}
> +
> /* 32 bit ops */
>
> void tcg_gen_subfi_i32(TCGv_i32 ret, int32_t arg1, TCGv_i32 arg2)
> @@ -410,11 +415,6 @@ void tcg_gen_subfi_i32(TCGv_i32 ret, int32_t arg1,
> TCGv_i32 arg2)
> }
> }
>
> -void tcg_gen_subi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
> -{
> - tcg_gen_addi_i32(ret, arg1, -arg2);
> -}
> -
> void tcg_gen_neg_i32(TCGv_i32 ret, TCGv_i32 arg)
> {
> tcg_gen_op2_i32(INDEX_op_neg, ret, arg);
> @@ -1537,11 +1537,6 @@ void tcg_gen_subfi_i64(TCGv_i64 ret, int64_t arg1,
> TCGv_i64 arg2)
> }
> }
>
> -void tcg_gen_subi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
> -{
> - tcg_gen_addi_i64(ret, arg1, -arg2);
> -}
> -
> void tcg_gen_neg_i64(TCGv_i64 ret, TCGv_i64 arg)
> {
> tcg_gen_op2_i64(INDEX_op_neg, ret, arg);
> --
> 2.53.0
>