# US 2025/0123844 A1 · Method and apparatus for software-directed inhibiting of branch prediction in computing devices

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

- Number: US 2025/0123844 A1
- Document ID: US20250123844A1
- Status: Published application
- Kind: A1
- Application number: 18/380,409
- Filed: 2023-10-16
- Published: 2025-04-17
- Earliest claimed: 2023-10-16
- Assignees: Huawei Technologies Co., Ltd.
- Applicants: Huawei Technologies Co., Ltd.
- Inventors: Maziar GOUDARZI; Reza AZIMI; Viatcheslav STEPANOV
- Web page: https://patentgrep.com/patent/US20250123844A1

## CPC

- G06F 9/3806: {using address prediction, e.g. return stack, branch history buffer}
- G06F 8/443: {Optimisation}
- G06F 8/4451: {Avoiding pipeline stalls}
- G06F 9/3005: {to perform operations for flow control}
- G06F 9/30076: {to perform miscellaneous control operations, e.g. NOP}
- 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

Methods and apparatus for inhibiting branch prediction unit operations of a computer are provided. Program code is generated having instructions which inhibit branch prediction prior to a stable path being executed, the stable path being stable (e.g. with all instructions executed sequentially as they occur in memory) with high likelihood. The instructions when executed trigger such branch prediction unit inhibition. The instructions can be generated so as to have a high prevalence, length, or both, of stable paths.

## Claims

### Claim 1

A computer apparatus comprising a processor operatively coupled to memory, the apparatus configured to:
generate executable computer program code having a stable path which consists essentially of a plurality of instructions to be most probably executed in a sequence, the plurality of instructions occurring in the stable path contiguously according to the sequence;
the generating of the executable computer program code comprising arranging the computer program code to maximize a length of the stable path while respecting one or more conditions or constraints,
the generating of the executable computer program code comprising including an indicator therein to inhibit operation of a branch prediction unit during execution of the stable path; and
store the generated executable computer program code for subsequent use.

### Claim 2 (depends on 1)

The apparatus of claim 1, wherein the one or more constraints or conditions include maintaining at least a threshold probability that the plurality of instructions will be executed in sequence.

### Claim 3 (depends on 1)

The apparatus of claim 1, wherein the indicator is a specialized branch instruction which leads to the stable path, a marker instruction, an instruction included in the computer program code along with but separate from a branch instruction which leads to the stable path, or an instruction which precedes the stable path by a fixed number of instructions and which indicates a start of the stable path.

### Claim 4 (depends on 1)

The apparatus of claim 1, wherein the arranging comprises generating, executing and analyzing candidate versions of the executable program code, and adjusting the candidate versions of the program code to arrive at the generated executable program code based on the analyzing.

### Claim 5 (depends on 4)

The apparatus of claim 4, wherein the analyzing comprises determining an indication of probability that the plurality of instructions will be executed in sequence.

### Claim 6

A computer apparatus comprising a processor operatively coupled to memory and a branch prediction unit, the apparatus configured to:
execute computer program code stored in memory and having a stable path which consists essentially of a plurality of instructions to be most probably executed in a sequence, the plurality of instructions occurring in the stable path contiguously according to the sequence;
read, in the computer program code, an indicator corresponding to the stable path approaching execution, the indicator included in the computer program code during generation thereof; and
in response to reading the indicator, inhibit operation of the branch prediction unit during at least one subsequent execution of the stable path.

### Claim 7 (depends on 6)

The apparatus of claim 6, wherein the indicator is that the stable path is about to be executed or is predicted to be executed.

### Claim 8 (depends on 6)

The apparatus of claim 6, wherein the indicator is associated with a branch instruction leading to the stable path.

### Claim 9 (depends on 6)

The apparatus of claim 6, wherein the indicator is associated with a start of the stable path.

### Claim 10 (depends on 6)

The apparatus of claim 6, wherein inhibiting operation of the branch prediction unit comprises storing data in a data structure which is also used for support operation of the branch prediction unit, the stored data used in triggering said inhibiting operation of the branch prediction unit during at least one subsequent execution of the stable path.

### Claim 11 (depends on 6)

The apparatus of claim 6, wherein inhibiting operation of the branch prediction unit comprises storing data in a data structure which is dedicated for use in triggering said inhibiting operation of the branch prediction unit during at least one subsequent execution of the stable path.

### Claim 12 (depends on 6)

The apparatus of claim 6, wherein the indicator is included in the computer program code as a specialized branch instruction which leads to the stable path.

### Claim 13 (depends on 6)

The apparatus of claim 6, wherein the indicator is included in the computer program code along with but separate from a branch instruction which leads to the stable path.

### Claim 14 (depends on 6)

The apparatus of claim 6, wherein the indicator is included in the computer program code as an instruction which precedes the stable path by a fixed number of instructions and which indicates a start of the stable path.

### Claim 15 (depends on 6)

The apparatus of claim 6, wherein the indicator indicates a length of the stable path and the apparatus is configured to cease inhibiting operation of the branch prediction unit following execution of the stable path.

### Claim 16

A non-transitory computer readable medium having stored thereon computer program code comprising:
a stable path which consists essentially of a plurality of instructions to be most probably executed in a sequence, the plurality of instructions occurring in the stable path contiguously according to the sequence;
an indicator in the computer program code and corresponding to the stable path approaching execution, the indicator included in the computer program code during generation thereof;
wherein in response to the indicator being read by a computer apparatus executing the computer program code, the apparatus inhibits operation of the branch prediction unit during at least one subsequent execution of the stable path.

### Claim 17

A method comprising, by a computer:
generating executable computer program code having a stable path which consists essentially of a plurality of instructions to be most probably executed in a sequence, the plurality of instructions occurring in the stable path contiguously according to the sequence;
the generating of the executable computer program code comprising arranging the computer program code to maximize a length of the stable path while respecting one or more conditions or constraints,
the generating of the executable computer program code comprising including an indicator therein to inhibit operation of a branch prediction unit during execution of the stable path; and
storing the generated executable computer program code for subsequent use.

### Claim 18

A method comprising, by a computer having a branch prediction unit:
executing computer program code stored in memory and having a stable path which consists essentially of a plurality of instructions to be most probably executed in a sequence, the plurality of instructions occurring in the stable path contiguously according to the sequence;
reading, in the computer program code, an indicator corresponding to the stable path approaching execution, the indicator included in the computer program code during generation thereof; and
in response to reading the indicator, inhibiting operation of the branch prediction unit during at least one subsequent execution of the stable path.
