Docsity

Conditional Instructions and Predicated Operations in Pipelined Processors, Slides of Advanced Computer Architecture

Partial preview of the text

Download Conditional Instructions and Predicated Operations in Pipelined Processors and more Slides Advanced Computer Architecture in PDF only on Docsity!

Conditional Instructions

Typical conditional instructions for pipeline processors are:

Conditional Move โ€“ CMOVZ R1, R2, R

it moves the value from one register to another if the condition is true; i.e., third operand โ€“ the predicate register R3 is Zero

Such instructions are used to eliminate branch code sequence

Conditional Instructions

Conditional ADD โ€“

(R8) ADD R1, R2, R

assumes that the R1= R2+R3 occurs if the predicate register โ€“ R8 is 1

Conditional or predicated Instructions: Example 1

Let us consider the conditional

statement:

If (A==0) { S=T;}

i.e., the value S is to be replaced by T if the value A is zero Assuming the register R1, R2, R3 holds the value of A, S and T respectively.

Example 1 The code to implement this conditional statements can be written as: BNEZ R1, L ; No-op if A (R1)!= 0 ADDU R2, R3, R0 ; Else replace S (R2) by T (R3) L The IF statement can be implemented by the conditional move as:

CMOVZ R2, R3, R Move R3 to R2 if the third operand R1=

Conditional or predicated Instructions

This transformation has moved the place to resolve dependence in a pipelined processor

We know that, in a pipelined processor the dependence for branches is resolved near the front of the pipe

Whereas, the conditional instruction resolve the dependence where the register-write occurs

Conditional or predicated Instructions

This transformation is also used for vector computers, where it is called if-conversion The if-conversion replaces conditional branches with predicated operations For example: Let see the code generated for the following two (2) if-then-else statements

Conditional or predicated Instructions

Alternatively two CMPP instruction of the form:

p1,p2 = CMPP.W. < UN. UC r1,r

Absolute Value Function: Example 2

Conditional move is also used to implement the absolute value function: A= abs (B) Which is implemented as: if B<0 {A=-B;} else {A=B;} Where this statement can be implemented as

  • pair of conditional moves CMOVZ R2, -R3, R CMOVZ R2, R3, R
  • or one unconditional move A=B and one conditional move A= - B

Conditional MOVE Instructions

When predication is used to eliminate branches that guard the execution of large blocks of code, many conditional moves are needed

To remedy this inefficiency, some architectures supports full predication, i.e.; the execution of all the instructions is controlled by a predicated move

Conditional MOVE Instructions

Full predictions allows to convert the large blocks of code that are branch dependent.

For example, if-then-else statement within a loop converted to predicated execution.

Where code executes only if the value of the condition is true.

The code in the else case executes only if the value of the condition is false.

2-Issue Instruction Code

First instruction slot second instruction slot

LW R1,40 R2) ADD R3,R4,R

ADD R6,R3,R

BEQZ R10,L

LW R8,0R10)

LW R9,0 R8)