From f17450483ef9dc18d2b97e6287063a572c7e898c Mon Sep 17 00:00:00 2001 From: iximeow Date: Sun, 29 Jan 2023 17:45:10 -0800 Subject: move some unlikely checks behind a branch that implies their possibility slightly fewer (perfectly predicted anyway) branches this way --- src/long_mode/mod.rs | 76 ++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs index 4862bcb..59d552c 100644 --- a/src/long_mode/mod.rs +++ b/src/long_mode/mod.rs @@ -7218,20 +7218,20 @@ fn read_operands< }; }, 3 => { - if modrm == 0xf8 { - instruction.opcode = Opcode::XABORT; - instruction.imm = read_imm_signed(words, 1)? as u64; - sink.record( - words.offset() as u32 * 8 - 8, - words.offset() as u32 * 8 - 1, - InnerDescription::Number("imm", instruction.imm as i64) - .with_id(words.offset() as u32 * 8 - 8) - ); - instruction.operands[0] = OperandSpec::ImmI8; - instruction.operand_count = 1; - return Ok(()); - } if (modrm & 0b00111000) != 0 { + if modrm == 0xf8 { + instruction.opcode = Opcode::XABORT; + instruction.imm = read_imm_signed(words, 1)? as u64; + sink.record( + words.offset() as u32 * 8 - 8, + words.offset() as u32 * 8 - 1, + InnerDescription::Number("imm", instruction.imm as i64) + .with_id(words.offset() as u32 * 8 - 8) + ); + instruction.operands[0] = OperandSpec::ImmI8; + instruction.operand_count = 1; + return Ok(()); + } sink.record( modrm_start + 3, modrm_start + 5, @@ -7254,32 +7254,32 @@ fn read_operands< } 4 => { - if modrm == 0xf8 { - instruction.opcode = Opcode::XBEGIN; - instruction.imm = if opwidth == 2 { - let imm = read_imm_signed(words, 2)? as i16 as i64 as u64; - sink.record( - words.offset() as u32 * 8 - 16, - words.offset() as u32 * 8 - 1, - InnerDescription::Number("imm", instruction.imm as i64) - .with_id(words.offset() as u32 * 8 - 16) - ); - imm - } else { - let imm = read_imm_signed(words, 4)? as i32 as i64 as u64; - sink.record( - words.offset() as u32 * 8 - 32, - words.offset() as u32 * 8 - 1, - InnerDescription::Number("imm", instruction.imm as i64) - .with_id(words.offset() as u32 * 8 - 32) - ); - imm - }; - instruction.operands[0] = OperandSpec::ImmI32; - instruction.operand_count = 1; - return Ok(()); - } if (modrm & 0b00111000) != 0 { + if modrm == 0xf8 { + instruction.opcode = Opcode::XBEGIN; + instruction.imm = if opwidth == 2 { + let imm = read_imm_signed(words, 2)? as i16 as i64 as u64; + sink.record( + words.offset() as u32 * 8 - 16, + words.offset() as u32 * 8 - 1, + InnerDescription::Number("imm", instruction.imm as i64) + .with_id(words.offset() as u32 * 8 - 16) + ); + imm + } else { + let imm = read_imm_signed(words, 4)? as i32 as i64 as u64; + sink.record( + words.offset() as u32 * 8 - 32, + words.offset() as u32 * 8 - 1, + InnerDescription::Number("imm", instruction.imm as i64) + .with_id(words.offset() as u32 * 8 - 32) + ); + imm + }; + instruction.operands[0] = OperandSpec::ImmI32; + instruction.operand_count = 1; + return Ok(()); + } sink.record( modrm_start + 3, modrm_start + 5, -- cgit v1.1