摘要:
A method and apparatus is disclosed for folding the execution of a multi-way branch or switch based upon an operand (e.g.,the block of instructions normally associated with a case statement) into a single instruction. This insulates branch prediction mechanisms from making incorrect predictions that are normally associated with a multi-way branch. A table saves the past history of multi-way branch execution. This table contains three fields: the starting address of a multi-way branch; a value of the operand used to execute that multi-way branch in the past; and the larger target address generated by that multi-way branch in the past when that particular operand value was used. In accordance with one embodiment of this invention, other branch prediction mechanisms (such as a Branch History Table or Decode History Table) are disabled from redirecting instruction fetching during execution of a multi-way branch in an instruction stream.