From 0637f629067c0aa8777466fa8e6e3ac4280356b1 Mon Sep 17 00:00:00 2001 From: iximeow Date: Thu, 1 Jul 2021 21:03:04 -0700 Subject: reorder prefix checks this measures a bit faster. it doesn't seem like it should be. the rex prefix checks compile identically but move a lea for a later expression up and pipelines better? --- src/long_mode/mod.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/long_mode') diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs index d04a091..65b1a35 100644 --- a/src/long_mode/mod.rs +++ b/src/long_mode/mod.rs @@ -6980,22 +6980,23 @@ fn read_instr::Address, = 0x40 && b < 0x50 { prefixes.rex_from(b); - } else if b == 0x0f { - let b = words.next().ok().ok_or(DecodeError::ExhaustedInput)?; - if b == 0x38 { - let b = words.next().ok().ok_or(DecodeError::ExhaustedInput)?; - break read_0f38_opcode(b, &mut prefixes); - } else if b == 0x3a { - let b = words.next().ok().ok_or(DecodeError::ExhaustedInput)?; - break read_0f3a_opcode(b, &mut prefixes); - } else { - break read_0f_opcode(b, &mut prefixes); - } } else if let Interpretation::Instruction(_) = record.0 { break record; } else { + if b == 0x0f { + let b = words.next().ok().ok_or(DecodeError::ExhaustedInput)?; + if b == 0x38 { + let b = words.next().ok().ok_or(DecodeError::ExhaustedInput)?; + break read_0f38_opcode(b, &mut prefixes); + } else if b == 0x3a { + let b = words.next().ok().ok_or(DecodeError::ExhaustedInput)?; + break read_0f3a_opcode(b, &mut prefixes); + } else { + break read_0f_opcode(b, &mut prefixes); + } + } // some prefix seen after we saw rex, but before the 0f escape or an actual // opcode. so we must forget the rex prefix! // this is to handle sequences like 41660f21cf -- cgit v1.1