Move loop inside the if block
@@ -1198,16 +1198,12 @@ impl<'a> Decoder<'a> {
// The calculated usize is a valid pointer in `self.data` slice or at most 1 byte past the last valid byte.
self.max_data_ptr = cmp::min(data_ptr + IcedConstants::MAX_INSTRUCTION_LENGTH, self.data_ptr_end);
+ let mut b = self.read_u8();
+ // SAFETY: `prefixes` is 256 bits in size (8 u32s) and `0<=b<=0xFF`, so this is safe
+ if (((*self.prefixes.add(b / 32)) >> (b & 31)) & 1) != 0 {
let mut default_ds_segment = Register::DS;
- let mut rex_prefix: usize = 0;
- let mut b;
+ let mut rex_prefix: usize;
loop {
- b = self.read_u8();
- // SAFETY: `prefixes` is 256 bits in size (8 u32s) and `0<=b<=0xFF`, so this is safe
- if (((*self.prefixes.add(b / 32)) >> (b & 31)) & 1) == 0 {
- break;
- }
-
match b {
0x26 => {
if !self.is64_mode || default_ds_segment < Register::FS {
@@ -1280,6 +1276,11 @@ impl<'a> Decoder<'a> {
rex_prefix = b;
}
}
+ b = self.read_u8();
+ // SAFETY: `prefixes` is 256 bits in size (8 u32s) and `0<=b<=0xFF`, so this is safe
+ if (((*self.prefixes.add(b / 32)) >> (b & 31)) & 1) == 0 {
+ break;
+ }
}
if rex_prefix != 0 {
if (rex_prefix & 8) != 0 {
@@ -1292,6 +1293,7 @@ impl<'a> Decoder<'a> {
self.state.extra_index_register_base = (rex_prefix as u32 & 2) << 2;
self.state.extra_base_register_base = (rex_prefix as u32 & 1) << 3;
}
+ }
// SAFETY: `0<=b<=0xFF` and `handlers` has exactly 256 elements
self.decode_table2(*self.handlers_xx.add(b), instruction);
