Don't unroll a loop if x87 top of stack is different at the start and end of the loop. Fixes Battlezone.

This commit is contained in:
SarahW 2019-05-11 11:44:33 +01:00
commit 83f2869123
3 changed files with 13 additions and 3 deletions

View file

@ -34,9 +34,10 @@ int codegen_can_unroll_full(codeblock_t *block, ir_data_t *ir, uint32_t next_pc,
int start;
int max_unroll;
int first_instruction;
int TOP = -1;
/*Check that dest instruction was actually compiled into block*/
start = codegen_get_instruction_uop(block, dest_addr, &first_instruction);
start = codegen_get_instruction_uop(block, dest_addr, &first_instruction, &TOP);
/*Couldn't find any uOPs corresponding to the destination instruction*/
if (start == -1)
@ -48,8 +49,14 @@ int codegen_can_unroll_full(codeblock_t *block, ir_data_t *ir, uint32_t next_pc,
return 0;
}
else
{
start = ir->wr_pos;
TOP = cpu_state.TOP;
}
}
if (TOP != cpu_state.TOP)
return 0;
max_unroll = UNROLL_MAX_UOPS / ((ir->wr_pos-start)+6);
if (max_unroll > (UNROLL_MAX_REG_REFERENCES / max_version_refcount))