SlideShare a Scribd company logo
1 of 15
Dynamic Branch
Prediction
1-BIT PREDICTION
Dynamic Branch Prediction(1-bit Prediction)
Dynamic Branch Prediction; the prediction changes while program
behavior changes.
It differs from Static Branch Prediction through gather level. The
prediction is gathered before the program execution at SBP but it is gathered
at run-time at DBP.
1-bit Prediction; is the simplest way to prediction. Once you
misprediction, then it is changed at next time.
2-bit Prediction is used as better solution.
Dynamic Branch Prediction(1-bit Prediction)
BT BNT
not taken
taken
taken not taken
1-bit Prediction Scheme;
Dynamic Branch Prediction(1-bit Prediction)
 Let’s evaluate below example;
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
Assume that Initial State is
Branch Taken
Dynamic Branch Prediction(1-bit Prediction)
For
i=0
If For
i=1
If For
i=2
If For
i=3
If For
i=4
If For
i=5
Result BT BNT BT BNT BT BN
T
BT BT BT BNT BNT
Prediction BT BT
1
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
BT BNT
not taken
taken
taken not taken
Our inital state is BT and
branch is taken at for
loop so we can decade
next prediction state is
Branch Taken. We
decade this prediction
through graph at right. If
your state is BT and
result is taken, the
prediction for is
statement is BT
Dynamic Branch Prediction(1-bit Prediction)
For
i=0
If For
i=1
If For
i=2
If For
i=3
If For
i=4
If For
i=5
Result BT BNT BT BNT BT BN
T
BT BT BT BNT BNT
Prediction BT BT BN
1 0
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
BT BNT
not taken
taken
taken not taken
Our current state is BT
and branch is not taken
at if condition so we can
decade next prediction
state is Branch Not
Taken. According to
graph at right, if our
state is Branch Taken
and state is not taken,
our prediction is Branch
Not Taken
Dynamic Branch Prediction(1-bit Prediction)
For
i=0
If For
i=1
If For
i=2
If For
i=3
If For
i=4
If For
i=5
Result BT BNT BT BNT BT BN
T
BT BT BT BNT BNT
Prediction BT BT BNT BT
1 0 0
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
BT BNT
not taken
taken
taken not taken
Our current state is BNT
and branch is taken at
for loop so we can
decade next prediction
state is Branch Taken.
According to graph at
right, if our state is
Branch Not Taken and
state is taken, our
prediction is Branch
Taken
Dynamic Branch Prediction(1-bit Prediction)
For
i=0
If For
i=1
If For
i=2
If For
i=3
If For
i=4
If For
i=5
Result BT BNT BT BNT BT BN
T
BT BT BT BNT BNT
Prediction BT BT BNT BT BNT
1 0 0 0
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
BT BNT
not taken
taken
taken not taken
Our current state is BT
and branch is not taken
at if condition so we can
decade next prediction
state is Branch Not
Taken. According to
graph at right, if our
state is Branch Taken
and state is not taken,
our prediction is Branch
Not Taken
Dynamic Branch Prediction(1-bit Prediction)
For
i=0
If For
i=1
If For
i=2
If For
i=3
If For
i=4
If For
i=5
Result BT BNT BT BNT BT BN
T
BT BT BT BNT BNT
Prediction BT BT BNT BT BNT BT
1 0 0 0 0
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
BT BNT
not taken
taken
taken not taken
Our current state is BNT
and branch is taken at
for loop so we can
decade next prediction
state is Branch Taken.
According to graph at
right, if our state is
Branch Not Taken and
state is taken, our
prediction is Branch
Taken
Dynamic Branch Prediction(1-bit Prediction)
For
i=0
If For
i=1
If For
i=2
If For
i=3
If For
i=4
If For
i=5
Result BT BNT BT BNT BT BN
T
BT BT BT BNT BNT
Prediction BT BT BNT BT BNT BT BNT
1 0 0 0 0 0
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
BT BNT
not taken
taken
taken not taken
Our current state is BT
and branch is not taken
at if condition so we can
decade next prediction
state is Branch Not
Taken. According to
graph at right, if our
state is Branch Taken
and state is not taken,
our prediction is Branch
Not Taken
Dynamic Branch Prediction(1-bit Prediction)
For
i=0
If For
i=1
If For
i=2
If For
i=3
If For
i=4
If For
i=5
Result BT BNT BT BNT BT BN
T
BT BT BT BNT BNT
Prediction BT BT BNT BT BNT BT BNT BT
1 0 0 0 0 0 0
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
BT BNT
not taken
taken
taken not taken
Our current state is BNT
and branch is taken at
for loop so we can
decade next prediction
state is Branch Taken.
According to graph at
right, if our state is
Branch Not Taken and
state is taken, our
prediction is Branch
Taken
Dynamic Branch Prediction(1-bit Prediction)
For
i=0
If For
i=1
If For
i=2
If For
i=3
If For
i=4
If For
i=5
Result BT BNT BT BNT BT BN
T
BT BT BT BNT BNT
Prediction BT BT BNT BT BNT BT BNT BT BT
1 0 0 0 0 0 0 1
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
BT BNT
not taken
taken
taken not taken
Our current state is BT
and branch is taken at if
condition so we can
decade next prediction
state is Branch Taken.
According to graph at
right, if our state is
Branch Taken and state
is taken, our prediction is
Branch Taken
Dynamic Branch Prediction(1-bit Prediction)
For
i=0
If For
i=1
If For
i=2
If For
i=3
If For
i=4
If For
i=5
Result BT BNT BT BNT BT BN
T
BT BT BT BNT BNT
Prediction BT BT BNT BT BNT BT BNT BT BT BT
1 0 0 0 0 0 0 1 1
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
BT BNT
not taken
taken
taken not taken
Our current state is BT
and branch is taken at if
condition so we can
decade next prediction
state is Branch Taken.
According to graph at
right, if our state is
Branch Taken and state
is taken, our prediction is
Branch Taken
Dynamic Branch Prediction(1-bit Prediction)
For
i=0
If For
i=1
If For
i=2
If For
i=3
If For
i=4
If For
i=5
Result BT BNT BT BNT BT BN
T
BT BT BT BNT BNT
Prediction BT BT BNT BT BNT BT BNT BT BT BT BNT
1 0 0 0 0 0 0 1 1 0
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
BT BNT
not taken
taken
taken not taken
Our current state is BT
and branch is not taken
at if condition so we can
decade next prediction
state is Branch Not
Taken. According to
graph at right, if our
state is Branch Taken
and state is not taken,
our prediction is Branch
Not Taken
Dynamic Branch Prediction(1-bit Prediction)
For
i=0
If For
i=1
If For
i=2
If For
i=3
If For
i=4
If For
i=5
Result BT BNT BT BNT BT BN
T
BT BT BT BNT BNT
Prediction BT BT BNT BT BNT BT BNT BT BT BT BNT
1 0 0 0 0 0 0 1 1 0 1
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
At the end;
Our 4 predictions are
correct!

More Related Content

Recently uploaded

1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
AldoGarca30
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
Kamal Acharya
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 

Recently uploaded (20)

Linux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using PipesLinux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
fitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .pptfitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .ppt
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdf
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Ground Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth ReinforcementGround Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth Reinforcement
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Signal Processing and Linear System Analysis
Signal Processing and Linear System AnalysisSignal Processing and Linear System Analysis
Signal Processing and Linear System Analysis
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptx
 

Featured

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

Dynamic Branch Prediction - 1 Bit Predicition

  • 2. Dynamic Branch Prediction(1-bit Prediction) Dynamic Branch Prediction; the prediction changes while program behavior changes. It differs from Static Branch Prediction through gather level. The prediction is gathered before the program execution at SBP but it is gathered at run-time at DBP. 1-bit Prediction; is the simplest way to prediction. Once you misprediction, then it is changed at next time. 2-bit Prediction is used as better solution.
  • 3. Dynamic Branch Prediction(1-bit Prediction) BT BNT not taken taken taken not taken 1-bit Prediction Scheme;
  • 4. Dynamic Branch Prediction(1-bit Prediction)  Let’s evaluate below example; … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … Assume that Initial State is Branch Taken
  • 5. Dynamic Branch Prediction(1-bit Prediction) For i=0 If For i=1 If For i=2 If For i=3 If For i=4 If For i=5 Result BT BNT BT BNT BT BN T BT BT BT BNT BNT Prediction BT BT 1 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … BT BNT not taken taken taken not taken Our inital state is BT and branch is taken at for loop so we can decade next prediction state is Branch Taken. We decade this prediction through graph at right. If your state is BT and result is taken, the prediction for is statement is BT
  • 6. Dynamic Branch Prediction(1-bit Prediction) For i=0 If For i=1 If For i=2 If For i=3 If For i=4 If For i=5 Result BT BNT BT BNT BT BN T BT BT BT BNT BNT Prediction BT BT BN 1 0 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … BT BNT not taken taken taken not taken Our current state is BT and branch is not taken at if condition so we can decade next prediction state is Branch Not Taken. According to graph at right, if our state is Branch Taken and state is not taken, our prediction is Branch Not Taken
  • 7. Dynamic Branch Prediction(1-bit Prediction) For i=0 If For i=1 If For i=2 If For i=3 If For i=4 If For i=5 Result BT BNT BT BNT BT BN T BT BT BT BNT BNT Prediction BT BT BNT BT 1 0 0 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … BT BNT not taken taken taken not taken Our current state is BNT and branch is taken at for loop so we can decade next prediction state is Branch Taken. According to graph at right, if our state is Branch Not Taken and state is taken, our prediction is Branch Taken
  • 8. Dynamic Branch Prediction(1-bit Prediction) For i=0 If For i=1 If For i=2 If For i=3 If For i=4 If For i=5 Result BT BNT BT BNT BT BN T BT BT BT BNT BNT Prediction BT BT BNT BT BNT 1 0 0 0 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … BT BNT not taken taken taken not taken Our current state is BT and branch is not taken at if condition so we can decade next prediction state is Branch Not Taken. According to graph at right, if our state is Branch Taken and state is not taken, our prediction is Branch Not Taken
  • 9. Dynamic Branch Prediction(1-bit Prediction) For i=0 If For i=1 If For i=2 If For i=3 If For i=4 If For i=5 Result BT BNT BT BNT BT BN T BT BT BT BNT BNT Prediction BT BT BNT BT BNT BT 1 0 0 0 0 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … BT BNT not taken taken taken not taken Our current state is BNT and branch is taken at for loop so we can decade next prediction state is Branch Taken. According to graph at right, if our state is Branch Not Taken and state is taken, our prediction is Branch Taken
  • 10. Dynamic Branch Prediction(1-bit Prediction) For i=0 If For i=1 If For i=2 If For i=3 If For i=4 If For i=5 Result BT BNT BT BNT BT BN T BT BT BT BNT BNT Prediction BT BT BNT BT BNT BT BNT 1 0 0 0 0 0 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … BT BNT not taken taken taken not taken Our current state is BT and branch is not taken at if condition so we can decade next prediction state is Branch Not Taken. According to graph at right, if our state is Branch Taken and state is not taken, our prediction is Branch Not Taken
  • 11. Dynamic Branch Prediction(1-bit Prediction) For i=0 If For i=1 If For i=2 If For i=3 If For i=4 If For i=5 Result BT BNT BT BNT BT BN T BT BT BT BNT BNT Prediction BT BT BNT BT BNT BT BNT BT 1 0 0 0 0 0 0 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … BT BNT not taken taken taken not taken Our current state is BNT and branch is taken at for loop so we can decade next prediction state is Branch Taken. According to graph at right, if our state is Branch Not Taken and state is taken, our prediction is Branch Taken
  • 12. Dynamic Branch Prediction(1-bit Prediction) For i=0 If For i=1 If For i=2 If For i=3 If For i=4 If For i=5 Result BT BNT BT BNT BT BN T BT BT BT BNT BNT Prediction BT BT BNT BT BNT BT BNT BT BT 1 0 0 0 0 0 0 1 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … BT BNT not taken taken taken not taken Our current state is BT and branch is taken at if condition so we can decade next prediction state is Branch Taken. According to graph at right, if our state is Branch Taken and state is taken, our prediction is Branch Taken
  • 13. Dynamic Branch Prediction(1-bit Prediction) For i=0 If For i=1 If For i=2 If For i=3 If For i=4 If For i=5 Result BT BNT BT BNT BT BN T BT BT BT BNT BNT Prediction BT BT BNT BT BNT BT BNT BT BT BT 1 0 0 0 0 0 0 1 1 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … BT BNT not taken taken taken not taken Our current state is BT and branch is taken at if condition so we can decade next prediction state is Branch Taken. According to graph at right, if our state is Branch Taken and state is taken, our prediction is Branch Taken
  • 14. Dynamic Branch Prediction(1-bit Prediction) For i=0 If For i=1 If For i=2 If For i=3 If For i=4 If For i=5 Result BT BNT BT BNT BT BN T BT BT BT BNT BNT Prediction BT BT BNT BT BNT BT BNT BT BT BT BNT 1 0 0 0 0 0 0 1 1 0 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … BT BNT not taken taken taken not taken Our current state is BT and branch is not taken at if condition so we can decade next prediction state is Branch Not Taken. According to graph at right, if our state is Branch Taken and state is not taken, our prediction is Branch Not Taken
  • 15. Dynamic Branch Prediction(1-bit Prediction) For i=0 If For i=1 If For i=2 If For i=3 If For i=4 If For i=5 Result BT BNT BT BNT BT BN T BT BT BT BNT BNT Prediction BT BT BNT BT BNT BT BNT BT BT BT BNT 1 0 0 0 0 0 0 1 1 0 1 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … At the end; Our 4 predictions are correct!