• retagged by
29,763 views
95 95 votes

Delayed branching can help in the handling of control hazards

For all delayed conditional branch instructions, irrespective of whether the condition evaluates to true or false,

  1. The instruction following the conditional branch instruction in memory is executed

  2. The first instruction in the fall through path is executed

  3. The first instruction in the taken path is executed

  4. The branch takes longer to execute than any other instruction

5 Answers

Best answer
106 106 votes
Answer is A. In order to avoid the pipeline delay due to conditional branch instruction, a suitable instruction is placed below the conditional branch instruction such that the instruction will be executed irrespective of whether branch is taken or not and won't affect the program behaviour.
• selected by
32 32 votes

Delayed branching is a solution to handle the control hazards. 

Delayed Branching Idea: Just give the CPU something to execute…

Detailed Video Explanation: Delayed Branch Solution for Control Hazards

One way to maximize the use of the pipeline, is to find an instruction that can be safely exeucted whether the branch is taken or not, and execute that instruction. So, when a branch instruction is encountered, the hardware puts the instruction following the branch into the pipe and begins executing it, just as in predict-not-taken. However, unlike in predict-not-taken, we do not need to worry about whether the branch is taken or not, we do not need to clear the pipe because no matter whether the branch is taken or not, we know the instruction is safe to execute. How do we know? The compiler promised it would be safe.

When the program was compiled, the compiler looked at each branch instruction, and tried to find something that could be safely executed, whether we take the branch or not.

https://www.cs.umd.edu/users/meesh/cmsc411/website/projects/branches/delay.html 

Delayed Branching - define the branch such that one (or two) instruction(s) after the branch will always be executed.

Compiler automatically rearranges code to fill the delayed-branch slot(s) with instructions that can always be executed. Instructions in the delayed-branch slot(s) do not need to be flushed after branching. If no instruction can be found to fill the delayed-branch slot(s), the a NOOP instruction is inserted.

https://www.cs.uni.edu/~fienup/cs240f03/lectures/lec21_11-4-03_control_hazards.htm 

Branch delay slots. The ISA is constructed such that one or more instructions sequentially following a conditional branch instruction are executed whether or not the branch is taken. The compiler or assembly language writer must fill these branch delay slots with useful instructions or NOPs (no-operation opcodes). This solution doesn't extend well to deeper pipelines, and becomes architectural baggage that the ISA must carry into future implementations. 

https://people.engr.tamu.edu/djimenez/taco/utsa-www/cs5513-fall07/lecture4.html 

https://www.cs.umd.edu/~meesh/411/CA-online/chapter/handling-control-hazards/index.html 

• edited by
0 0 votes

img source: carl hamacher

a technique to reduce the penalty for branch instructions is Delayed branching

The location that follows a branch instruction is called the branch delay slot, the compiler attempts to find a suitable instruction to occupy the delay slot (for eg add is inserted below the branch instruction), one that needs to be executed even when the branch is taken.

Instruction Ij+1 is fetched only if the branch is not taken.

branching takes place one instruction later than where the branch instruction appears in the instruction sequence. This technique is called delayed branching.

therefore in the question as said  irrespective of whether the condition evaluates to true or false,

the instruction following the conditional branch instruction in memory is executed.

Option A

 

Answer:
Position:
Show:

Related questions

74 74 votes
4 answers 4 answers
36.1k
36.1k views
Kathleen asked Sep 12, 2014
36,073 views
Which of the following are NOT true in a pipelined processor?Bypassing can handle all RAW hazardsRegister renaming can eliminate all register carried WAR hazardsControl h...
80 80 votes
7 answers 7 answers
26.9k
26.9k views
go_editor asked Apr 23, 2016
26,882 views
Delayed branching can help in the handling of control hazardsThe following code is to run on a pipelined processor with one branch delay slot:I1: ADD $R2 \leftarrow R7 + ...
79 79 votes
11 answers 11 answers
34.1k
34.1k views
go_editor asked Sep 28, 2014
34,097 views
Consider a $6$-stage instruction pipeline, where all stages are perfectly balanced. Assume that there is no cycle-time overhead of pipelining. When an application is exec...
200 200 votes
9 answers 9 answers
79.3k
79.3k views
Kathleen asked Sep 22, 2014
79,287 views
A $5$ stage pipelined CPU has the following sequence of stages:IF – instruction fetch from instruction memoryRD – Instruction decode and register readEX – Execute: ALU op...