# US 2021/0240477 A1 · Indirect Branch Predictor Based on Register Operands

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0240477 A1
- Document ID: US20210240477A1
- Status: Published application
- Kind: A1
- Application number: 16/778,939
- Filed: 2020-01-31
- Published: 2021-08-05
- Earliest claimed: 2020-01-31
- Assignees: Apple Inc.
- Applicants: Apple Inc.
- Inventors: Muawya M. Al-Otoom; Ian D. Kountanis; Conrado Blasco; Haoyan Jia; Amit Kumar
- Web page: https://patentgrep.com/patent/US20210240477A1

## CPC

- G06F 9/3806: {using address prediction, e.g. return stack, branch history buffer}
- G06F 9/3844: {using dynamic branch prediction, e.g. using branch history tables}
- G06F 9/3848: {using hybrid branch prediction, e.g. selection between prediction techniques}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

In an embodiment, an indirect branch predictor generates indirect branch predictions based on one or more register values. The register values may be the contents of registers on which the indirect branch instruction is directly or indirectly dependent for generating the branch target address, for example. In an embodiment, at least one of the registers may be a source for a load instruction, and the indirect branch may be dependent (directly or indirectly) on the target of the load. In an embodiment, the indirect branch predictor may be one of at least two indirect branch predictors in a processor. The other indirect branch predictor may be based on a fetch address, or PC, associated with the indirect branch instruction. The other indirect branch predictor may generate a first predicted target address, and the indirect branch predictor may generate a second predicted target address for the same indirect branch instruction.

## Claims

### Claim 1

A processor comprising:
a first indirect branch predictor configured to predict a first predicted target address of an indirect branch instruction responsive to an instruction fetch address; and
a second indirect branch predictor configured to predict a second predicted target address of the indirect branch instruction responsive to one or more register values, wherein the one or more register values are operands of instructions prior to the indirect branch instruction in program order, and wherein the second indirect branch predictor is configured to redirect instruction fetching of the processor to the second predicted target address responsive to the second predicted target address differing from the first predicted target address.

### Claim 2 (depends on 1)

The processor as recited in claim 1 further comprising an execution unit configured to execute an indirect branch instruction operation corresponding to the indirect branch instruction, wherein the execution unit is configured to generate an actual target address of the indirect branch instruction and to redirect instruction fetching of the processor responsive to the actual target address differing from the second predicted target address.

### Claim 3 (depends on 1)

The processor as recited in claim 1 wherein the second indirect branch predictor includes a memory and an index generation circuit coupled the memory, wherein the index generation circuit is configured to generate an index to address the memory responsive to the one or more register values, wherein the memory is configured to output one or more addresses from a memory location addressed by the index.

### Claim 4 (depends on 3)

The processor as recited in claim 3 wherein the memory is configured to output one or more tags corresponding to the one or more addresses, wherein the second indirect branch predictor is configured to select the second predicted target address from the one or more addresses responsive to the one or more tags.

### Claim 5 (depends on 1)

The processor as recited in claim 1 wherein the second indirect branch predictor is configured not to redirect fetching from the first predicted target address responsive to the second predicted target address matching the first predicted target address.

### Claim 6 (depends on 1)

The processor as recited in claim 1 further comprising a decode unit configured to decode the indirect branch instruction into a first instruction operation that, when executed, accesses the second indirect branch predictor and a second instruction operation that, when executed, performs an indirect branch operation.

### Claim 7 (depends on 6)

The processor as recited in claim 6 wherein the first instruction operation has one or more registers that store the one or more register values as source operands.

### Claim 8 (depends on 6)

The processor as recited in claim 6 wherein the second instruction operation has a dependency on the first instruction operation.

### Claim 9 (depends on 6)

The processor as recited in claim 6 wherein the decode unit includes one or more configuration registers that are programmed with data identifying the indirect branch instruction, wherein other indirect branch instructions are not predicted by the second indirect branch predictor.

### Claim 10

An indirect branch predictor comprising:
an index generation circuit configured to generate an index from one or more register values associated with an indirect branch instruction;
a memory coupled to the index generation circuit and configured to output at least one predicted target address responsive to the index; and
a control circuit coupled to the memory, wherein the control circuit is configured to select a predicted target address for the indirect branch instruction from the at least one predicted target address.

### Claim 11 (depends on 10)

The indirect branch predictor as recited in claim 10 further comprising a comparator coupled to the predicted target address and coupled to a second predicted target address previously generated for the indirect branch instruction.

### Claim 12 (depends on 11)

The indirect branch predictor as recited in claim 11 wherein, responsive to a miscompare between the predicted target address and the second predicted target address, the comparator is configured to signal a redirect for the indirect branch instruction.

### Claim 13 (depends on 12)

The indirect branch predictor as recited in claim 12 wherein, responsive to the predicted target address and the second predicted target address comparing equal, the comparator signals no redirect and fetching continues with instructions at the predicted target address.

### Claim 14 (depends on 10)

The indirect branch predictor as recited in claim 10 further comprising a training queue coupled to the control circuit, wherein the control circuit is configured to allocate a first entry in the training queue responsive to receiving the one or more register values, and wherein the control circuit is configured to initialize data in the first entry to identify a memory location in the memory from which the predicted target address is selected.

### Claim 15 (depends on 14)

The indirect branch predictor as recited in claim 14 wherein the control circuit is configured to update the first entry responsive to execution of an indirect branch operation corresponding to the indirect branch instruction, the update including the actual branch target address and an indication of whether or not the indirect branch instruction was mispredicted at execution of the indirect branch operation.

### Claim 16 (depends on 14)

The indirect branch predictor as recited in claim 14 wherein the control circuit is configured to update the memory from the first entry responsive to retirement of the indirect branch instruction.

### Claim 17

A method comprising:
predicting a first target address of an indirect branch instruction responsive to one or more register values, wherein at least one of the one or more register values is a source register for a load operation on which the indirect branch instruction is dependent;
determining whether or not the first target address is mispredicted; and
responsive to the first target address being mispredicted, training an indirect branch predictor that generated the first target address with the actual target address generated during execution of the indirect branch instruction.

### Claim 18 (depends on 17)

The method as recited in claim 17 further comprising:
comparing the first target address to a previous target address predicted by a different indirect branch predict; and
redirecting fetch from the previous target address to the first target address responsive to the comparing indicating not equal.

### Claim 19 (depends on 17)

The method as recited in claim 17 further comprising redirecting fetch in a processor including the indirect branch predictor responsive to the first target address being mispredicted.

### Claim 20 (depends on 17)

The method as recited in claim 17 wherein the indirect branch instruction is indirectly dependent on the load operation.
