02-12-09-Opti

From Msim

Jump to: navigation, search

This refers to the optimization When checking the LSQ for a store forward, the for loop was not used effectively.


This is just a code cleanup.

The original code:

unsigned int i = (rs - &contexts[rs->context_id].LSQ[0]);
if(i != contexts[rs->context_id].LSQ_head)
{
 for(;;)
 {
  //go to next earlier LSQ entry
  i = (i + (contexts[rs->context_id].LSQ.size()-1)) % contexts[rs->context_id].LSQ.size();
  
  //FIXME: not dealing with partials!
  if((MD_OP_FLAGS(contexts[rs->context_id].LSQ[i].op) & F_STORE) && (contexts[rs->context_id].LSQ[i].addr == rs->addr))
  {
   //hit in the LSQ
   load_lat = 1;
   break;
  }
  
  //scan finished?
  if(i == contexts[rs->context_id].LSQ_head)
  {
   break;
  }
 }
}



The revised code:

for(unsigned int i = (rs - &contexts[rs->context_id].LSQ[0]);i != contexts[rs->context_id].LSQ_head;;)
{
 //go to next earlier LSQ entry
 i = (i + (contexts[rs->context_id].LSQ.size()-1)) % contexts[rs->context_id].LSQ.size();
 
 //FIXME: not dealing with partials!
 if((MD_OP_FLAGS(contexts[rs->context_id].LSQ[i].op) & F_STORE) && (contexts[rs->context_id].LSQ[i].addr == rs->addr))
 {
  //hit in the LSQ
  load_lat = 1;
  break;
 }
}
Personal tools