Dealing with Branches | Computer Architecture & Organisation (CAO) - Computer Science Engineering (CSE) PDF Download

Dealing with Branches
Until the instruction is actually executed, it is impossible to determine whether the branch will be taken or not. A variety of approaches have been taken for dealing with conditional branches:
• Multiple streams
• Prefetch branch target
• Loop buffer
• Branch prediction
• Delayed branch 

Multiple Streams
 A simple pipeline suffers a penalty for a branch instruction because it must choose one of two instructions to fetch next and may make the wrong choice.

A brute-force approach is to replicate the initial portions of the pipeline and allow the pipeline to fetch both instructions, making use of two streams. There are two problems with this approach:
• With multiple pipelines there are contention delays for access to the registers and to memory.
• Additional branch instructions may enter the pipeline (either stream) before the original branch decision is resolved. Each such instruction needs an additional stream.

Examples of machines with two or more pipeline streams are the IBM 370/168 and the IBM 3033.

PREFETCH BRANCH TARGET When a conditional branch is recognized, the target of the branch is prefetched, in addition to the instruction following the branch. This target is then saved until the branch instruction is executed. If the branch is taken, the target has already been prefetched. 

Loop Buffer
 A loop buffer is a small, very-high-speed memory maintained by the instruction fetch stage of the pipeline and containing the n most recently fetched instructions, in sequence. If a branch is to be taken, the hardware first checks whether the branch target is within the buffer. If so, the next instruction is fetched from the buffer.

The loop buffer has three benefits:
1. With the use of prefetching, the loop buffer will contain some instruction sequentially ahead of the current instruction fetch address.
2. If a branch occurs to a target just a few locations ahead of the address of the branch instruction,the target will already be in the buffer.
3. This strategy is particularly well suited to dealing with loops, or iterations; hence the name loop buffer. If the loop buffer is large enough to contain all the instructions in a loop, then those instructions need to be fetched from memory only once, for the first iteration. For subsequent iterations, all the needed instructions are already in the buffer.

Figure 3.8 gives an example of a loop buffer

Dealing with Branches | Computer Architecture & Organisation (CAO) - Computer Science Engineering (CSE)

Branch Prediction
 Various techniques can be used to predict whether a branch will be taken. Among the more common are the following:
• Predict never taken
• Predict always taken
• Predict by opcode
• Taken/not taken switch
• Branch history table

The first three approaches are static: they do not depend on the execution history up to the time of the conditional branch instruction. The latter two approaches are dynamic: They depend on the execution history.

The first two approaches are the simplest. These either always assume that the branch will not be taken or continue to fetch instructions in sequence, or they always assume that the branch will be taken and always fetch from the branch target. The predict-never-taken approach is the most popular of all the branch prediction methods.

Delayed Branch
 It is possible to improve pipeline performance by automatically rearranging instructions within a program, so that branch instructions occur later than actually desired.

The document Dealing with Branches | Computer Architecture & Organisation (CAO) - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Computer Architecture & Organisation (CAO).
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
20 videos|86 docs|48 tests

Top Courses for Computer Science Engineering (CSE)

FAQs on Dealing with Branches - Computer Architecture & Organisation (CAO) - Computer Science Engineering (CSE)

1. What are the common IT branches in the field of computer science and engineering?
Ans. The common IT branches in the field of computer science and engineering include software engineering, computer networking, information technology, data science, and cybersecurity.
2. What is the role of software engineering in the IT industry?
Ans. Software engineering involves designing, developing, testing, and maintaining software systems. It plays a crucial role in the IT industry by creating innovative software solutions that meet the needs of businesses and users.
3. How does computer networking contribute to the IT field?
Ans. Computer networking is essential in the IT field as it enables the exchange of data and information between devices and systems. It establishes connections, enables communication, and facilitates resource sharing, making it a vital component of modern IT infrastructure.
4. What is the significance of information technology in today's world?
Ans. Information technology is significant in today's world as it enables the storage, retrieval, and transmission of information. It supports businesses in managing their operations, facilitates communication and collaboration, and drives innovation across various industries.
5. How does cybersecurity play a role in protecting IT systems?
Ans. Cybersecurity plays a crucial role in protecting IT systems by safeguarding them from potential threats, such as unauthorized access, data breaches, and malware attacks. It involves implementing security measures, setting up firewalls, conducting regular audits, and educating users about safe online practices.
20 videos|86 docs|48 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Previous Year Questions with Solutions

,

Dealing with Branches | Computer Architecture & Organisation (CAO) - Computer Science Engineering (CSE)

,

MCQs

,

practice quizzes

,

Important questions

,

mock tests for examination

,

Sample Paper

,

study material

,

Extra Questions

,

Dealing with Branches | Computer Architecture & Organisation (CAO) - Computer Science Engineering (CSE)

,

Viva Questions

,

past year papers

,

Summary

,

shortcuts and tricks

,

Exam

,

pdf

,

Free

,

Semester Notes

,

Objective type Questions

,

video lectures

,

ppt

,

Dealing with Branches | Computer Architecture & Organisation (CAO) - Computer Science Engineering (CSE)

;