IP Library Granted Patent US 9,298,467
Granted Patent B2
US 9,298,467 · App. 14/153,188 · Granted Mar 29, 2016

Switch statement prediction

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 9,298,467
App. No.
14/153,188
Granted
Mar 29, 2016
Kind
B2
Abstract

Methods and branch predictors for predicting a target location of a jump table switch statement in a program. The method includes continuously monitoring instructions at the branch predictor to determine if they write to registers used to store an input variable to a jump table switch statement. Any update to a monitored register is stored in a register table maintained by the branch predictor. Then when it comes time to make a prediction for a jump table switch statement instruction the branch predictor uses the register value stored in the table is used to predict where the jump table switch statement will branch to.

Claims (58)

1. A method to predict a target location of a switch statement in a program executed by a processor, the method comprising:

storing, in a register table maintained by a branch predictor, a current value for at least one monitored register, each monitored register having been identified as storing an input variable to a jump table switch statement, a jump table switch statement being a switch statement that has been compiled to a jump table;

receiving at the branch predictor an instruction for prediction;

prior to the received instruction being executed, determining, using the branch predictor, whether the received instruction writes to one of the monitored registers with an update value;

in response to determining that the received instruction writes to one of the monitored registers with an update value, updating the current value in the register table for the monitored register the received instruction writes to with the update value; and

predicting, using the branch predictor, the target location of a jump table switch statement instruction using the current value.

2. The method according to claim 1 , further comprising:

receiving at the branch predictor another instruction for prediction;

determining, at the branch predictor, whether the other instruction is a jump table switch statement instruction;

in response to determining that the other instruction is a jump table switch statement instruction, determining whether the register table comprises a current value for the input variable to the jump table switch statement instruction; and

in response to determining that the register table comprises a current value for the input variable to the jump table switch statement instruction, predicting the target location of the jump table switch statement instruction using the current value.

3. The method according to claim 2 , wherein determining whether the other instruction is a jump table switch statement instruction comprises determining if the other instruction has a predetermined pattern.

4. The method according to claim 2 , further comprising:

in response to determining that the other instruction is a jump table switch statement instruction, making the register used to store the input variable to the jump table switch statement instruction a monitored register.

5. The method according to claim 4 , wherein making the register used to store the input variable to the jump table switch statement instruction a monitored register comprises storing in the register table information identifying the register used to store the input variable to the jump table switch statement instruction.

6. The method according to claim 5 , wherein determining whether the received instruction writes to one of the monitored registers comprises comparing the information in the register table identifying the registers used to store the input variables to the jump table switch statements to information in the received instruction identifying a write register.

7. The method according to claim 2 , further comprising:

in response to determining that the other instruction is a jump table switch statement instruction, determining whether the current value is to be used to predict the target location; and

in response to determining that the current value is to be used to predict the target location, predicting the target location of the jump table switch statement instruction using the current value.

8. The method according to claim 7 , wherein:

the register table further comprises at least one of a valid bit, a counter and a confidence value for each monitored register; and

determining whether the current value is to be used in predicting the target location comprises analyzing at least one of the valid bit, the counter and the confidence value.

9. The method according to claim 8 , wherein the register table comprises a valid bit for each monitored register, each valid bit indicates whether the current value for the monitored register is valid.

10. The method according to claim 8 , wherein the register table comprises a counter for each monitored register, each counter indicates how many times the current value for the monitored register has been used to predict a target location since it was updated; and determining whether the current value is to be used in predicting the target location comprises comparing the counter to a threshold value.

11. The method according to claim 8 , wherein the register table comprises a confidence value for each monitored register, each confidence value indicates the likelihood that that the current value for the monitored register will correctly predict the target location for the associated jump table switch statement; and determining whether the current value is to be used in predicting the target location comprises comparing the confidence value to a threshold value.

12. The method according to claim 1 , wherein predicting the target location of the jump table switch statement instruction using the current value comprises combining the program counter for the jump table switch statement instruction and the current value.

13. The method according to claim 12 , wherein combining the program counter for the jump table switch statement instruction and the current value comprises:

determining a program counter for the instruction immediately following the jump table switch statement instruction based on the program counter for the jump table switch statement instruction; and

multiplying the current value by a factor N to generate a scaled current value, wherein N is the size of an instruction; and

summing the program counter for the instruction immediately following the jump table switch statement instruction and the scaled current value.

14. The method according to claim 1 , wherein the register table comprises a plurality of rows and the rows are ordered in the register table based on how recently they have been accessed.

15. A branch predictor comprising:

a register table, the register table storing a current value for at least one monitored register, each monitored register storing an input variable to a jump table switch statement, a jump table switch statement being a switch statement that has been compiled to a jump table; and

a logic unit in communication with the register table, the logic unit configured to:

receive an instruction for prediction;

prior to the received instruction being executed, determine whether the received instruction writes to one of the monitored registers with an update value;

in response to determining that the received instruction writes to one of the monitored registers with an update value, update the current value in the register table for the monitored register the received instruction writes to with the update value; and

predict the target location of a jump table switch statement instruction using the current value.

16. The branch predictor according to claim 15 , wherein the logic unit is further configured to:

receive another instruction for prediction;

determine whether the other instruction is a jump table switch statement instruction;

in response to determining that the other instruction is a jump table switch statement instruction, determine whether the register table comprises a current value for the input variable to the jump table switch statement instruction; and

in response to determining that the register table comprises a current value for the input variable to the jump table switch statement instruction, predict the target location of the jump table switch statement instruction using the current value.

17. The branch predictor according to claim 16 , wherein the logic unit is further configured to:

in response to determining that the other instruction is a jump table switch statement instruction, make the register used to store the input variable to the jump table switch statement instruction a monitored register.

18. The branch predictor according to claim 16 , wherein

the register table is configured to store a confidence value for each monitored register, each confidence value in the register table indicates the likelihood that the current value for the monitored register will correctly predict the target location for the associated jump table switch statement; and

the logic unit is further configured to:

in response to determining that the other instruction is a jump table switch statement instruction, determine whether the current value is to be used to predict the target location by comparing the confidence value to a threshold value; and

in response to determining that the current value is to be used to predict the target location, predicting the target location of the jump table switch statement instruction using the current value.

19. The branch predictor according to claim 15 wherein predicting the target location of a jump table switch statement instruction using the current value comprises combining the program counter for the jump table switch statement instruction and the current value.

20. A processor comprising a branch predictor, the branch predictor comprising:

a register table, the register table storing a current value for at least one monitored register, each monitored register having been identified as storing an input variable to a jump table switch statement, a jump table switch statement being a switch statement that has been compiled to a jump table; and

a logic unit in communication with the register table, the logic unit configured to:

receive an instruction for prediction;

prior to the received instruction being executed, determine whether the received instruction writes to one of the monitored registers with an update value;

in response to determining that the received instruction writes to one of the monitored registers with an update value, update the current value in the register table for the monitored register the received instruction writes to with the update value; and

predict the target location of a jump table switch statement instruction using the current value.

Assignments (8)
RELEASE OF SECURITY INTEREST Recorded Dec 29, 2022
From: CAPITAL FINANCE ADMINISTRATION, LLC, AS ADMINISTRATIVE AGENT
To: MIPS TECH, LLC; WAVE COMPUTING INC.
Reel/Frame 062251/0251 →
SECURITY INTEREST Recorded Jun 14, 2021
From: MIPS TECH, LLC; WAVE COMPUTING, INC.
To: CAPITAL FINANCE ADMINISTRATION, LLC
Reel/Frame 056558/0903 →
RELEASE OF SECURITY INTEREST Recorded Jun 14, 2021
From: WAVE COMPUTING LIQUIDATING TRUST
To: MIPS TECH, INC.; HELLOSOFT, INC.; WAVE COMPUTING (UK) LIMITED; IMAGINATION TECHNOLOGIES, INC.; CAUSTIC GRAPHICS, INC.; MIPS TECH, LLC; WAVE COMPUTING, INC.
Reel/Frame 056589/0606 →
SECURITY INTEREST Recorded Feb 26, 2021
From: WAVE COMPUTING, INC.; MIPS TECH, LLC; MIPS TECH, INC.; HELLOSOFT, INC.; WAVE COMPUTING (UK) LIMITED; IMAGINATION TECHNOLOGIES, INC.; CAUSTIC GRAPHICS, INC.
To: WAVE COMPUTING LIQUIDATING TRUST
Reel/Frame 055429/0532 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Apr 19, 2018
From: MIPS TECH LIMITED
To: MIPS TECH, LLC
Reel/Frame 045593/0166 →
CHANGE OF NAME Recorded Jan 26, 2018
From: HELLOSOFT LIMITED
To: MIPS TECH LIMITED
Reel/Frame 045168/0922 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jan 24, 2018
From: IMAGINATION TECHNOLOGIES LIMITED
To: HELLOSOFT LIMITED
Reel/Frame 044712/0386 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jan 13, 2014
From: JACKSON, HUGH
To: IMAGINATION TECHNOLOGIES, LTD.
Reel/Frame 031949/0633 →