diff options
author | Mike Pall <mike> | 2015-02-21 21:44:41 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2015-02-21 21:44:41 +0100 |
commit | 4fa51affe8353ac8b39a41ccba69fb38101f7c3e (patch) | |
tree | f691595e4cfdeb7a88ed50443b1e65517be9e391 | |
parent | 704280fb80d5320b20f6cd20cfbf009a999164f0 (diff) | |
download | luajit-4fa51affe8353ac8b39a41ccba69fb38101f7c3e.tar.gz luajit-4fa51affe8353ac8b39a41ccba69fb38101f7c3e.tar.bz2 luajit-4fa51affe8353ac8b39a41ccba69fb38101f7c3e.zip |
x86/x64: Fix code generation for fused test/arith ops.
Thanks to Alexander Nasonov and AFL.
-rw-r--r-- | src/lj_asm_x86.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lj_asm_x86.h b/src/lj_asm_x86.h index bb6976f2..0b6b2d4a 100644 --- a/src/lj_asm_x86.h +++ b/src/lj_asm_x86.h | |||
@@ -1836,8 +1836,12 @@ static void asm_intarith(ASMState *as, IRIns *ir, x86Arith xa) | |||
1836 | Reg dest, right; | 1836 | Reg dest, right; |
1837 | int32_t k = 0; | 1837 | int32_t k = 0; |
1838 | if (as->flagmcp == as->mcp) { /* Drop test r,r instruction. */ | 1838 | if (as->flagmcp == as->mcp) { /* Drop test r,r instruction. */ |
1839 | as->flagmcp = NULL; | 1839 | MCode *p = as->mcp + ((LJ_64 && *as->mcp < XI_TESTb) ? 3 : 2); |
1840 | as->mcp += (LJ_64 && *as->mcp < XI_TESTb) ? 3 : 2; | 1840 | if ((p[1] & 15) < 14) { |
1841 | if ((p[1] & 15) >= 12) p[1] -= 4; /* L <->S, NL <-> NS */ | ||
1842 | as->flagmcp = NULL; | ||
1843 | as->mcp = p; | ||
1844 | } /* else: cannot transform LE/NLE to cc without use of OF. */ | ||
1841 | } | 1845 | } |
1842 | right = IR(rref)->r; | 1846 | right = IR(rref)->r; |
1843 | if (ra_hasreg(right)) { | 1847 | if (ra_hasreg(right)) { |