diff options
author | Mike Pall <mike> | 2010-12-07 01:18:10 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2010-12-07 01:18:10 +0100 |
commit | e6093b129a9f0fdfeff0a9775edc60cca5b36fa3 (patch) | |
tree | 0d4caccdf4a578d34fe8e3cd081a688d04357479 /src | |
parent | b3c4c0810a38c472df2dc0564c18c752114a796e (diff) | |
download | luajit-e6093b129a9f0fdfeff0a9775edc60cca5b36fa3.tar.gz luajit-e6093b129a9f0fdfeff0a9775edc60cca5b36fa3.tar.bz2 luajit-e6093b129a9f0fdfeff0a9775edc60cca5b36fa3.zip |
Fix register allocation for 8 bit stores in x86 backend.
Diffstat (limited to 'src')
-rw-r--r-- | src/lj_asm.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/lj_asm.c b/src/lj_asm.c index 096def55..944b9b78 100644 --- a/src/lj_asm.c +++ b/src/lj_asm.c | |||
@@ -2010,14 +2010,18 @@ static void asm_fxload(ASMState *as, IRIns *ir) | |||
2010 | static void asm_fxstore(ASMState *as, IRIns *ir) | 2010 | static void asm_fxstore(ASMState *as, IRIns *ir) |
2011 | { | 2011 | { |
2012 | RegSet allow = RSET_GPR; | 2012 | RegSet allow = RSET_GPR; |
2013 | Reg src = RID_NONE; | 2013 | Reg src = RID_NONE, osrc = RID_NONE; |
2014 | int32_t k = 0; | 2014 | int32_t k = 0; |
2015 | /* The IRT_I16/IRT_U16 stores should never be simplified for constant | 2015 | /* The IRT_I16/IRT_U16 stores should never be simplified for constant |
2016 | ** values since mov word [mem], imm16 has a length-changing prefix. | 2016 | ** values since mov word [mem], imm16 has a length-changing prefix. |
2017 | */ | 2017 | */ |
2018 | if (!asm_isk32(as, ir->op2, &k) || irt_isi16(ir->t) || irt_isu16(ir->t)) { | 2018 | if (!asm_isk32(as, ir->op2, &k) || irt_isi16(ir->t) || irt_isu16(ir->t)) { |
2019 | RegSet allow8 = (irt_isi8(ir->t) || irt_isu8(ir->t)) ? RSET_GPR8 : RSET_GPR; | 2019 | RegSet allow8 = (irt_isi8(ir->t) || irt_isu8(ir->t)) ? RSET_GPR8 : RSET_GPR; |
2020 | src = ra_alloc1(as, ir->op2, allow8); | 2020 | src = osrc = ra_alloc1(as, ir->op2, allow8); |
2021 | if (!LJ_64 && !rset_test(allow8, src)) { /* Already in wrong register. */ | ||
2022 | rset_clear(allow, osrc); | ||
2023 | src = ra_scratch(as, allow8); | ||
2024 | } | ||
2021 | rset_clear(allow, src); | 2025 | rset_clear(allow, src); |
2022 | } | 2026 | } |
2023 | if (ir->o == IR_FSTORE) | 2027 | if (ir->o == IR_FSTORE) |
@@ -2043,6 +2047,10 @@ static void asm_fxstore(ASMState *as, IRIns *ir) | |||
2043 | break; | 2047 | break; |
2044 | } | 2048 | } |
2045 | emit_mrm(as, xo, src, RID_MRM); | 2049 | emit_mrm(as, xo, src, RID_MRM); |
2050 | if (!LJ_64 && src != osrc) { | ||
2051 | ra_noweak(as, osrc); | ||
2052 | emit_rr(as, XO_MOV, src, osrc); | ||
2053 | } | ||
2046 | } else { | 2054 | } else { |
2047 | if (irt_isi8(ir->t) || irt_isu8(ir->t)) { | 2055 | if (irt_isi8(ir->t) || irt_isu8(ir->t)) { |
2048 | emit_i8(as, k); | 2056 | emit_i8(as, k); |