A method and apparatus are provided for improving the performance of
branch prediction using a combination of a speculative branch target
buffer (SBTB) and an architectural branch target buffer (ABTB). According
to one embodiment, speculative branch data is maintained for in-flight
branches (i.e., those that have been fetched but not yet retired). A
branch entry is speculatively allocated in a line of the SBTB after
decoding an instruction containing a branch, such as a conditional
branch, a return from a subroutine, a call to a subroutine, or an
unconditional branch. Subsequently, the branch data associated with the
branch entry is speculatively updated after branch prediction has been
completed for the branch. Finally, the branch data is corrected after the
branch has been executed. According to another embodiment, a novel branch
prediction circuit includes both a speculative branch target buffer
(SBTB) cache and an architectural branch target buffer (ABTB) cache. The
SBTB cache contains multiple branch entries to maintain speculative
branch data associated with in-flight branches. The speculative branch
data includes a speculative history of taken/not-taken outcomes
associated with the in-flight branches. The ABTB cache is coupled to the
SBTB cache. The ABTB cache also includes multiple branch entries,
however, they are for maintaining architectural branch data including the
actual taken/not-taken outcomes associated with retired conditional
branches.