From 262370046c896aeb2dd2eb7fd72980a162b9c6af Mon Sep 17 00:00:00 2001 From: Alexis Engelke Date: Sun, 19 Mar 2023 21:16:00 +0100 Subject: [PATCH] decode: Optimize handling of immediates --- decode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/decode.c b/decode.c index 45453ef..413982e 100644 --- a/decode.c +++ b/decode.c @@ -583,7 +583,8 @@ fd_decode(const uint8_t* buffer, size_t len_sz, int mode_int, uintptr_t address, } uint32_t imm_control = UNLIKELY(DESC_IMM_CONTROL(desc)); - if (UNLIKELY(imm_control == 1)) + if (LIKELY(!imm_control)) { + } else if (UNLIKELY(imm_control == 1)) { // 1 = immediate constant 1, used for shifts FdOp* operand = &instr->operands[DESC_IMM_IDX(desc)]; @@ -732,7 +733,7 @@ skip_modrm: } instr->size = off; - instr->operandsz = DESC_INSTR_WIDTH(desc) ? op_size - 1 : 0; + instr->operandsz = UNLIKELY(DESC_INSTR_WIDTH(desc)) ? op_size - 1 : 0; return off; }