From a9c28d42dfabde804d60e17da488983aeaf517b2 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Mon, 21 May 2018 22:11:43 +0300 Subject: [PATCH] Fix JIT V-flag handling, V was always cleared. (addx, subx, negx, any instruction that used set_zero()) --- jit/codegen_x86.cpp | 2 ++ jit/gencomp.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/jit/codegen_x86.cpp b/jit/codegen_x86.cpp index 5784b25b..fe8d12e9 100644 --- a/jit/codegen_x86.cpp +++ b/jit/codegen_x86.cpp @@ -3389,10 +3389,12 @@ static __inline__ void raw_flags_set_zero_FLAGREG(int s, int tmp) { raw_mov_l_rr(tmp,s); raw_lahf(s); /* flags into ah */ + SETOr(X86_AL); /* V flag into al */ raw_and_l_ri(s,0xffffbfff); raw_and_l_ri(tmp,0x00004000); raw_xor_l_ri(tmp,0x00004000); raw_or_l(s,tmp); + raw_cmp_b_ri(X86_AL,-127); /* set V */ raw_sahf(s); } diff --git a/jit/gencomp.cpp b/jit/gencomp.cpp index ce78d68d..8d168cb1 100644 --- a/jit/gencomp.cpp +++ b/jit/gencomp.cpp @@ -1282,13 +1282,13 @@ genflags (flagtypes type, wordsizes size, const char *value, const char *src, co break; } comprintf("\tlive_flags();\n"); - comprintf("\tif (needed_flags&FLAG_Z) {\n" - "\tcmov_l_rr(zero,one,%d);\n" - "\tset_zero(zero, one);\n" /* No longer need one */ - "\tlive_flags();\n" - "\t}\n",NATIVE_CC_NE); + comprintf("\tif (needed_flags&FLAG_Z) {\n"); + comprintf("\tcmov_l_rr(zero,one,%d);\n", NATIVE_CC_NE); + comprintf("\tset_zero(zero, one);\n"); /* No longer need one */ + comprintf("\tlive_flags();\n"); + comprintf("\t}\n"); comprintf("\tend_needflags();\n"); - duplicate_carry(); + duplicate_carry(); comprintf("if (!(needed_flags & FLAG_CZNV)) dont_care_flags();\n"); return; } -- 2.47.3