IP Library Granted Patent US 12,373,215
Granted Patent B2
US 12,373,215 · App. 17/814,729 · Granted Jul 29, 2025

Using a next fetch predictor circuit with short branches and return fetch groups

Inventors: Niket K. Choudhary (Santa Clara, CA); Mary D. Brown (Austin, TX); Ethan R. Schuchman (Saratoga, CA); Ronald P. Hall (Cedar Park, TX); Ian D. Kountanis (Santa Clara, CA); Douglas C. Holman (San Francisco, CA); Ilhyun Kim (Portland, OR); Abhishek Kumar (Chicago, IL); Siavash Zangeneh Kamali (Austin, TX)
Assignee: Apple Inc.
G06F9/3802G06F12/0875G06F2212/452
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,373,215
App. No.
17/814,729
Granted
Jul 29, 2025
Kind
B2
Abstract

An apparatus includes an instruction cache circuit and an instruction fetch circuit. The instruction fetch circuit is configured to retrieve, from the instruction cache circuit, a fetch group that includes a plurality of instructions for execution by a processing circuit, and to make a determination that the fetch group includes a control transfer instruction that is predicted to be taken. A target address associated with the control transfer instruction is directed to an instruction within the fetch group. The instruction fetch circuit is further configured to, based on the determination, alter instructions within the fetch group in a manner that is based on a type of the control transfer instruction.

Claims (71)

1. An apparatus, comprising:

an instruction cache circuit;

a next fetch predictor circuit that includes an entry corresponding to a fetch address, wherein the entry includes a first target address of a first control transfer instruction in a fetch group associated with the fetch address; and

an instruction fetch circuit configured to:

retrieve, from the instruction cache circuit based on the fetch address, the fetch group that includes a plurality of instructions for execution by a processing circuit;

determine, based on the entry, that the fetch group includes the first control transfer instruction that is predicted to be taken and an instruction at the first target address; and

based on the determination:

add a tag to the entry, wherein the tag is indicative that the first target address and the first control transfer instruction are included in the fetch group;

determine that a second control transfer instruction is included in the fetch group, the second control transfer instruction having a second target address; and

update the entry to include the second target address in place of the first target address.

2. The apparatus of claim 1 , wherein the instruction fetch circuit is further configured to:

in response to a determination that the first control transfer instruction is a call instruction:

identify an address of an instruction after the call instruction as the first target address;

store, in an instruction buffer circuit, a first portion of the fetch group that includes instructions from a beginning of the fetch group to the call instruction;

store, in a return fetch stack circuit that is different from the instruction buffer circuit, a second portion of the fetch group starting with the instruction at the first target address; and

retrieve a next fetch group based on a target address of the call instruction.

3. The apparatus of claim 1 , wherein the instruction fetch circuit is further configured to:

in response to a determination that the first control transfer instruction is a backward branch instruction, store a first portion of the fetch group followed by a second portion of the fetch group in an instruction buffer; and

wherein the first and second portions of the fetch group each include at least the instruction at the first target address and the backward branch instruction.

4. The apparatus of claim 3 , wherein to determine that the first control transfer instruction is the backward branch instruction, the instruction fetch circuit is configured to determine that the backward branch instruction is taken more than a threshold number of consecutive times.

5. The apparatus of claim 1 , wherein the instruction fetch circuit is further configured to:

in response to a determination that the first control transfer instruction is a forward branch instruction:

store a first portion of the fetch group in an instruction buffer circuit, wherein the first portion of the fetch group includes instructions from a beginning of the fetch group to the forward branch instruction;

identify a second portion of the fetch group starting with the instruction at the first target address; and

store the second portion of the fetch group consecutive to the first portion in the instruction buffer circuit, omitting instructions between the forward branch instruction and the instruction at the first target address.

6. The apparatus of claim 1 , wherein the instruction fetch circuit is further configured to:

after a subsequent retrieval of the fetch group, determine, using the tag, that the fetch group includes the first control transfer instruction and the instruction at the first target address.

7. The apparatus of claim 6 , wherein the instruction fetch circuit is further configured to:

after an initial retrieval of the fetch group, retrieve a next fetch group based on the first target address; and

after the subsequent retrieval of the fetch group, skip a retrieval of the next fetch group based on the first target address.

8. A method, comprising:

storing, by a next fetch predictor circuit, a first target address of a first control transfer instruction into an entry corresponding to a fetch address;

retrieving, by an instruction fetch circuit using the fetch address, a fetch group that includes a plurality of instructions for execution by a processing circuit;

determining, by the instruction fetch circuit, that the fetch group includes the first control transfer instruction that is predicted to be taken and that the first target address is directed to an instruction included within the fetch group;

based on the determining that the fetch group includes the first control transfer instruction and the first target address:

adding a tag to the entry corresponding to the fetch address in the next fetch predictor circuit;

identifying a second target address of a second control transfer instruction in the fetch group; and

replacing the first target address with the second target address in the entry.

9. The method of claim 8 , wherein, in response to determining that the first control transfer instruction is a call instruction: using an address of an instruction that is subsequent to the call instruction as the first target address;

storing, in an instruction buffer circuit, a first portion of the fetch group that includes instructions from a beginning of the fetch group to the call instruction; and

storing, in a return fetch stack circuit that is different from the instruction buffer circuit, a second portion of the fetch group starting with the instruction at the first target address.

10. The method of claim 9 , further comprising:

retrieving a next fetch group based on a target address of the call instruction; and

in response to determining the next fetch group includes a return instruction, retrieving the second portion from the return fetch stack circuit.

11. The method of claim 8 , wherein, in response to determining that the first control transfer instruction is a backward branch instruction:

storing a first portion of the fetch group followed by a second portion of the fetch group in an instruction buffer, wherein the first and second portions of the fetch group each include at least the instruction at the first target address and the backward branch instruction.

12. The method of claim 11 , further comprising determining that the first control transfer instruction is the backward branch instruction in response to determining that the backward branch instruction is taken more than a threshold number of consecutive times.

13. The method of claim 8 , wherein, in response to determining that the first control transfer instruction is a forward branch instruction: storing the fetch group in an instruction buffer circuit by omitting instructions between the forward branch instruction and the instruction at the first target address.

14. A system comprising:

an instruction cache circuit configured to store a plurality of instructions;

a next fetch predictor circuit configured to store, in an entry corresponding to a particular fetch address, a first target address of a first control transfer instruction in a fetch group; and

an instruction fetch circuit configured to:

retrieve, using the particular fetch address, the fetch group from the plurality of instructions in the instruction cache circuit;

determine, using the entry from the next fetch predictor circuit, that the first control transfer instruction is predicted to be taken and that the first target address is included in the fetch group;

in response to the determination:

tag the entry in the next fetch predictor circuit;

identify a second target address of a second control transfer instruction in the fetch group; and

replace the first target address with the second target address in the entry.

15. The system of claim 14 , wherein the instruction fetch circuit is further configured to:

retrieve, using the particular fetch address subsequent to the tagging, the fetch group from the instruction cache circuit, including the predicted taken first control transfer instruction; and

in response to the tagged entry, bypass the next fetch predictor circuit for determining the first target address of the predicted taken first control transfer instruction.

16. The system of claim 15 , wherein the instruction fetch circuit is further configured to:

store a first portion of the fetch group in an instruction buffer circuit in an order in which the first portion was fetched; and

store a second portion of the fetch group in the instruction buffer circuit in an order that differs from an order in which the second portion was fetched relative to the first portion, wherein the second portion is based on the first target address and a type of the predicted taken first control transfer instruction.

17. The system of claim 15 , wherein, in response to a determination that the first control transfer instruction is a call instruction, the instruction fetch circuit is further configured to:

identify an address subsequent to an address of the call instruction as the first target address.

18. The system of claim 15 , wherein, in response to a determination that the predicted taken first control transfer instruction is a backward branch instruction, the instruction fetch circuit is further configured to:

determine that the first target address is between the particular fetch address and an address of the backward branch instruction, inclusive.

19. The system of claim 18 , wherein to tag the entry, the instruction fetch circuit is further configured to determine that the backward branch instruction is taken more than a threshold number of consecutive times.

20. The system of claim 15 , wherein, in response to a determination that the first control transfer instruction is a forward branch instruction, the instruction fetch circuit is further configured to:

determine that the first target address, corresponding to a target address of the forward branch instruction, is between an address of the forward branch instruction and a last address of the fetch group.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jul 25, 2022
From: CHOUDHARY, NIKET K.; BROWN, MARY D.; SCHUCHMAN, ETHAN R.; HALL, RONALD P.; KOUNTANIS, IAN D.; HOLMAN, DOUGLAS C.; KIM, ILHYUN; KUMAR, ABHISHEK; ZANGENEH KAMALI, SIAVASH
To: APPLE INC.
Reel/Frame 060609/0340 →
Continuity (1)
Related Publication 20240028339A1 · Jan 25, 2024
References Cited (24)
US 5799180A · Shiell · 1998 [cited by examiner]
US 5889986A · Nguyen · 1999 [cited by examiner]
US 5951679A · Anderson · 1999 [cited by examiner]
US 6385719B1 · Derrick et al. · 2002 [cited by applicant]
US 6578138B1 · Kyker · 2003 [cited by examiner]
US 7475231B2 · Tran · 2009 [cited by examiner]
US 8578141B2 · Jarvis · 2013 [cited by examiner]
US 9052910B2 · Hall · 2015 [cited by examiner]
US 10445102B1 · Pistol · 2019 [cited by examiner]
US 10747539B1 · Hakewill et al. · 2020 [cited by applicant]
US 11256505B2 · Annamalai · 2022 [cited by examiner]
US 20050198481A1 · Henry · 2005 [cited by examiner]
US 20060095746A1 · Uchiyama et al. · 2006 [cited by applicant]
US 20120117362A1 · Bhargava et al. · 2012 [cited by applicant]
US 20120290821A1 · Shah et al. · 2012 [cited by applicant]
US 20130339699A1 · Blasco-Allue · 2013 [cited by examiner]
US 20140075156A1 · Blasco-Allue et al. · 2014 [cited by applicant]
US 20140136822A1 · Suggs · 2014 [cited by examiner]
US 20140344558A1 · Holman et al. · 2014 [cited by applicant]
US 20150169041A1 · Blasco · 2015 [cited by examiner]
US 20150205613A1 · Bhatia · 2015 [cited by examiner]
US 20150293577A1 · Hall · 2015 [cited by examiner]
US 20200150966A1 · Agrawal et al. · 2020 [cited by applicant]
International Search Report and Written Opinion in PCT Appl. No. PCT/US2023/025570 mailed Oct. 5, 2023, 8 pages. [cited by applicant]