LOAD_GLOBAL + PUSH_NULL -> LOAD_GLOBAL , NOP
(&mut self)
| 1426 | |
| 1427 | /// LOAD_GLOBAL <even> + PUSH_NULL -> LOAD_GLOBAL <odd>, NOP |
| 1428 | fn optimize_load_global_push_null(&mut self) { |
| 1429 | for block in &mut self.blocks { |
| 1430 | let mut i = 0; |
| 1431 | while i + 1 < block.instructions.len() { |
| 1432 | let curr = &block.instructions[i]; |
| 1433 | let next = &block.instructions[i + 1]; |
| 1434 | |
| 1435 | let (Some(Instruction::LoadGlobal { .. }), Some(Instruction::PushNull)) = |
| 1436 | (curr.instr.real(), next.instr.real()) |
| 1437 | else { |
| 1438 | i += 1; |
| 1439 | continue; |
| 1440 | }; |
| 1441 | |
| 1442 | let oparg = u32::from(block.instructions[i].arg); |
| 1443 | if (oparg & 1) != 0 { |
| 1444 | i += 1; |
| 1445 | continue; |
| 1446 | } |
| 1447 | |
| 1448 | block.instructions[i].arg = OpArg::new(oparg | 1); |
| 1449 | block.instructions.remove(i + 1); |
| 1450 | } |
| 1451 | } |
| 1452 | } |
| 1453 | |
| 1454 | /// Convert LOAD_CONST for small integers to LOAD_SMALL_INT |
| 1455 | /// maybe_instr_make_load_smallint |
no test coverage detected