tcg/i386: convert add/sub of 128 to sub/add of -128
PATCH 1/1 tcg/i386: convert add/sub of 128 to sub/add of -128
Signed-off-by Paolo Bonzini <[email protected]>
--- tcg/i386/tcg-target.c.inc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tcg/i386/tcg-target.c.inc +5 -1
@@ -1332,7 +1332,11 @@ static void tgen_arithi(TCGContext *s, int c, int r0, return; } - if (c == ARITH_AND) { + if ((c == ARITH_ADD || c == ARITH_SUB) && val == 128) { + /* Facilitate using an 8-bit immediate. */ + c ^= ARITH_ADD ^ ARITH_SUB; + val = -128; + } else if (c == ARITH_AND) { if (TCG_TARGET_REG_BITS == 64) { if (val == 0xffffffffu) { tcg_out_ext32u(s, r0, r0);
Signature · 1 line
2.43.0
Quoted 12 lines · Paolo Bonzini
Signed-off-by Paolo Bonzini <[email protected]>--- tcg/i386/tcg-target.c.inc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tcg/i386/tcg-target.c.inc +0
-0@@ -1332,7 +1332,11 @@ static void tgen_arithi(TCGContext *s, int c, int r0, return; }
tcg/i386/tcg-target.c.inc static void tgen_arithi(TCGContext *s, int c, int r0, · line 1342
Quoted 10 lines
tcg/i386/tcg-target.c.inc +5
-1- if (c == ARITH_AND) { + if ((c == ARITH_ADD || c == ARITH_SUB) && val == 128) { + /* Facilitate using an 8-bit immediate. */ + c ^= ARITH_ADD ^ ARITH_SUB; + val = -128; + } else if (c == ARITH_AND) { if (TCG_TARGET_REG_BITS == 64) { if (val == 0xffffffffu) { tcg_out_ext32u(s, r0, r0);
Need to check for !cf, because this swaps the sense of carry. Ought to merge this with the inc/dec block above to save comparisons.
r~