From 510862e50c4016a6ac5557712b7e01e8d58bece0 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sun, 25 Apr 2021 23:19:32 +0100 Subject: [PATCH] backend/x64: Change V flag testing to cmp instead of add Prefer a non-destructive read to a destructive read. --- src/backend/x64/emit_x64.cpp | 12 ++++++------ src/backend/x64/emit_x64_data_processing.cpp | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/backend/x64/emit_x64.cpp b/src/backend/x64/emit_x64.cpp index a71200c5..817de5f5 100644 --- a/src/backend/x64/emit_x64.cpp +++ b/src/backend/x64/emit_x64.cpp @@ -219,11 +219,11 @@ Xbyak::Label EmitX64::EmitCond(IR::Cond cond) { code.jns(pass); break; case IR::Cond::VS: //v - code.add(al, 0x7F); + code.cmp(al, 0x81); code.jo(pass); break; case IR::Cond::VC: //!v - code.add(al, 0x7F); + code.cmp(al, 0x81); code.jno(pass); break; case IR::Cond::HI: //c & !z @@ -237,22 +237,22 @@ Xbyak::Label EmitX64::EmitCond(IR::Cond cond) { code.jna(pass); break; case IR::Cond::GE: // n == v - code.add(al, 0x7F); + code.cmp(al, 0x81); code.sahf(); code.jge(pass); break; case IR::Cond::LT: // n != v - code.add(al, 0x7F); + code.cmp(al, 0x81); code.sahf(); code.jl(pass); break; case IR::Cond::GT: // !z & (n == v) - code.add(al, 0x7F); + code.cmp(al, 0x81); code.sahf(); code.jg(pass); break; case IR::Cond::LE: // z | (n != v) - code.add(al, 0x7F); + code.cmp(al, 0x81); code.sahf(); code.jle(pass); break; diff --git a/src/backend/x64/emit_x64_data_processing.cpp b/src/backend/x64/emit_x64_data_processing.cpp index eadbf222..5a3d179d 100644 --- a/src/backend/x64/emit_x64_data_processing.cpp +++ b/src/backend/x64/emit_x64_data_processing.cpp @@ -171,11 +171,11 @@ static void EmitConditionalSelect(BlockOfCode& code, EmitContext& ctx, IR::Inst* code.cmovns(else_, then_); break; case IR::Cond::VS: //v - code.add(nzcv.cvt8(), 0x7F); + code.cmp(nzcv.cvt8(), 0x81); code.cmovo(else_, then_); break; case IR::Cond::VC: //!v - code.add(nzcv.cvt8(), 0x7F); + code.cmp(nzcv.cvt8(), 0x81); code.cmovno(else_, then_); break; case IR::Cond::HI: //c & !z @@ -189,22 +189,22 @@ static void EmitConditionalSelect(BlockOfCode& code, EmitContext& ctx, IR::Inst* code.cmovna(else_, then_); break; case IR::Cond::GE: // n == v - code.add(nzcv.cvt8(), 0x7F); + code.cmp(nzcv.cvt8(), 0x81); code.sahf(); code.cmovge(else_, then_); break; case IR::Cond::LT: // n != v - code.add(nzcv.cvt8(), 0x7F); + code.cmp(nzcv.cvt8(), 0x81); code.sahf(); code.cmovl(else_, then_); break; case IR::Cond::GT: // !z & (n == v) - code.add(nzcv.cvt8(), 0x7F); + code.cmp(nzcv.cvt8(), 0x81); code.sahf(); code.cmovg(else_, then_); break; case IR::Cond::LE: // z | (n != v) - code.add(nzcv.cvt8(), 0x7F); + code.cmp(nzcv.cvt8(), 0x81); code.sahf(); code.cmovle(else_, then_); break;