SlideShare a Scribd company logo
1 of 15
Dynamic Branch
Prediction
2-BIT PREDICTION
Dynamic Branch Prediction(2-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.
2-bit Prediction; is better than 1-bit to prediction. If you misprediction at
twice, it is changed at next time.
Dynamic Branch Prediction(2-bit Prediction)
BT BT
not taken
taken
taken
2-bit Prediction Scheme;
BNT BNT
taken
not taken
not taken
not taken taken
Dynamic Branch Prediction(2-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;
}
…
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
BT BT
not taken
taken
taken
BNT BNT
taken
not taken
not taken
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 BT
1 0
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
Our current state is BT
(strongly) and branch is
not 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
(strongly) and state is
not taken, our prediction
is Branch Taken
BT BT
not taken
taken
taken
BNT BNT
taken
not taken
not taken
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 BT BT
1 0 1
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
Our current state is BT
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 Taken and state
is taken, our prediction is
Branch Taken
BT BT
not taken
taken
taken
BNT BNT
taken
not taken
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 BT BT BT
1 0 1 0
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
Our current state is BT
(strongly) and branch is
not 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
(strongly) and state is
not taken, our prediction
is Branch Taken
BT BT
not taken
taken
taken
BNT BNT
taken
not taken
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 BT BT BT BT
1 0 1 0 1
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
Our current state is BT
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 Taken and state
is taken, our prediction is
Branch Taken
BT BT
not taken
taken
taken
BNT BNT
taken
not taken
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 BT BT BT BT BT
1 0 1 0 1 0
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
Our current state is BT
(strongly) and branch is
not 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
(strongly) and state is
not taken, our prediction
is Branch Taken
BT BT
not taken
taken
taken
BNT BNT
taken
not taken
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 BT BT BT BT BT BT
1 0 1 0 1 0 1
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
Our current state is BT
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 Taken and state
is taken, our prediction is
Branch Taken
BT BT
not taken
taken
taken
BNT BNT
taken
not taken
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 BT BT BT BT BT BT BT
1 0 1 0 1 0 1 1
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
Our current state is BT
(strongly) 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
(strongly) and state is
taken, our prediction is
Branch Taken
BT BT
not taken
taken
taken
BNT BNT
taken
not taken
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 BT BT BT BT BT BT BT BT
1 0 1 0 1 0 1 1 1
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
Our current state is BT
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 Taken and state
is taken, our prediction is
Branch Taken
BT BT
not taken
taken
taken
BNT BNT
taken
not taken
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 BT BT BT BT BT BT BT BT BT
1 0 1 0 1 0 1 1 1 0
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
Our current state is BT
(strongly) and branch is
not 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
(strongly) and state is
not taken, our prediction
is Branch Taken
BT BT
not taken
taken
taken
BNT BNT
taken
not taken
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 BT BT BT BT BT BT BT BT BT
1 0 1 0 1 0 1 1 1 0 0
…
int a = 3;
int i = 0;
for(i =0;i<5;i++){
if(i == a)
a=0;
}
…
At the end;
Our 6 predictions are
correct!

More Related Content

Recently uploaded

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
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
pritamlangde
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 

Recently uploaded (20)

Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
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
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
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...
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 

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 - 2 Bit Predicition

  • 2. Dynamic Branch Prediction(2-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. 2-bit Prediction; is better than 1-bit to prediction. If you misprediction at twice, it is changed at next time.
  • 3. Dynamic Branch Prediction(2-bit Prediction) BT BT not taken taken taken 2-bit Prediction Scheme; BNT BNT taken not taken not taken not taken taken
  • 4. Dynamic Branch Prediction(2-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; } … 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 BT BT not taken taken taken BNT BNT taken not taken not taken not taken
  • 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 BT 1 0 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … Our current state is BT (strongly) and branch is not 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 (strongly) and state is not taken, our prediction is Branch Taken BT BT not taken taken taken BNT BNT taken not taken not taken 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 BT BT 1 0 1 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … Our current state is BT 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 Taken and state is taken, our prediction is Branch Taken BT BT not taken taken taken BNT BNT taken not taken not 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 BT BT BT 1 0 1 0 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … Our current state is BT (strongly) and branch is not 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 (strongly) and state is not taken, our prediction is Branch Taken BT BT not taken taken taken BNT BNT taken not taken 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 BT BT BT BT 1 0 1 0 1 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … Our current state is BT 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 Taken and state is taken, our prediction is Branch Taken BT BT not taken taken taken BNT BNT taken not taken not 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 BT BT BT BT BT 1 0 1 0 1 0 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … Our current state is BT (strongly) and branch is not 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 (strongly) and state is not taken, our prediction is Branch Taken BT BT not taken taken taken BNT BNT taken not taken 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 BT BT BT BT BT BT 1 0 1 0 1 0 1 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … Our current state is BT 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 Taken and state is taken, our prediction is Branch Taken BT BT not taken taken taken BNT BNT taken not taken not 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 BT BT BT BT BT BT BT 1 0 1 0 1 0 1 1 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … Our current state is BT (strongly) 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 (strongly) and state is taken, our prediction is Branch Taken BT BT not taken taken taken BNT BNT taken not taken not 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 BT BT BT BT BT BT BT BT 1 0 1 0 1 0 1 1 1 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … Our current state is BT 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 Taken and state is taken, our prediction is Branch Taken BT BT not taken taken taken BNT BNT taken not taken not 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 BT BT BT BT BT BT BT BT BT 1 0 1 0 1 0 1 1 1 0 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … Our current state is BT (strongly) and branch is not 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 (strongly) and state is not taken, our prediction is Branch Taken BT BT not taken taken taken BNT BNT taken not taken 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 BT BT BT BT BT BT BT BT BT 1 0 1 0 1 0 1 1 1 0 0 … int a = 3; int i = 0; for(i =0;i<5;i++){ if(i == a) a=0; } … At the end; Our 6 predictions are correct!