• edited by
10,567 views
41 41 votes

Data forwarding techniques can be used to speed up the operation in presence of data dependencies. Consider the following replacements of LHS with RHS.

  1.  $R1→ Loc, Loc→ R2 \quad ≡  R1→ R2, R1 → Loc$
  2.  $R1→ Loc, Loc→ R2 \quad ≡ R1→ R2$
  3.  $R1→ Loc, R2 → Loc \quad ≡ R1→ Loc$
  4.  $R1→ Loc, R2 → Loc \quad ≡  R2→ Loc$

In which of the following options, will the result of executing the RHS be the same as executing the LHS irrespective of the instructions that follow ?

  1. i and iii
  2. i and iv
  3. ii and iii
  4. ii and iv

3 Answers

Best answer
59 59 votes
  1. is true. Both $LOC$ and $R2$ are getting the value of $R1$ in $LHS$ and $RHS$.
  2. false, because $R2$ gets the correct data in both $LHS$ and $RHS$, but $LOC$ is not updated in $RHS$.
  3. is wrong because $R2$ is writing last, not $R1$ in $LHS$, but not in $RHS$.
  4. is true. The first write to $LOC$ in $LHS$ is useless as it is overwritten by the next write.


So, answer is (B).

• edited by
0 0 votes
  Reason
i✅ YesR2 and Loc both get value of R1
ii❌ NoLoc not updated in RHS
iii❌ NoMissing second update to Loc
iv✅ YesLoc ends with R2’s value

Correct replacements are i and iv.
Ans: Option B

 

0 0 votes
\textbf{Answer: (i) and (iv)}

\section*{Explanation}

The notation is interpreted as follows:

\[
R_1 \rightarrow Loc : \text{Store the contents of register } R_1 \text{ into memory location } Loc
\]

\[
Loc \rightarrow R_2 : \text{Load the contents of memory location } Loc \text{ into register } R_2
\]

\[
R_1 \rightarrow R_2 : \text{Copy the contents of } R_1 \text{ directly into } R_2
\]

The replacements are examined below.

\subsection*{Option (i)}

\[
R_1 \rightarrow Loc,\; Loc \rightarrow R_2
\equiv
R_1 \rightarrow R_2,\; R_1 \rightarrow Loc
\]

LHS:
\[
\begin{aligned}
&Loc \leftarrow R_1,\\
&R_2 \leftarrow Loc
\end{aligned}
\]

After execution,
\[
Loc = R_1,\qquad R_2 = R_1.
\]

RHS:
\[
\begin{aligned}
&R_2 \leftarrow R_1,\\
&Loc \leftarrow R_1
\end{aligned}
\]

Again,
\[
Loc = R_1,\qquad R_2 = R_1.
\]

Both the register and memory contents are identical after execution.

\[
\boxed{\text{Option (i) is correct.}}
\]

\subsection*{Option (ii)}

\[
R_1 \rightarrow Loc,\; Loc \rightarrow R_2
\equiv
R_1 \rightarrow R_2
\]

LHS:
\[
Loc = R_1,\qquad R_2 = R_1.
\]

RHS:
\[
R_2 = R_1,\qquad Loc \text{ remains unchanged.}
\]

If a later instruction accesses memory location \(Loc\), the two executions produce different results.

\[
\boxed{\text{Option (ii) is incorrect.}}
\]

\subsection*{Option (iii)}

\[
R_1 \rightarrow Loc,\; R_2 \rightarrow Loc
\equiv
R_1 \rightarrow Loc
\]

LHS:
\[
Loc \leftarrow R_1,\qquad
Loc \leftarrow R_2.
\]

The second store overwrites the first, so

\[
Loc = R_2.
\]

RHS:

\[
Loc = R_1.
\]

Unless \(R_1 = R_2\), the final memory contents differ.

\[
\boxed{\text{Option (iii) is incorrect.}}
\]

\subsection*{Option (iv)}

\[
R_1 \rightarrow Loc,\; R_2 \rightarrow Loc
\equiv
R_2 \rightarrow Loc
\]

LHS:
\[
Loc \leftarrow R_1,\qquad
Loc \leftarrow R_2.
\]

Final value:
\[
Loc = R_2.
\]

RHS:
\[
Loc \leftarrow R_2.
\]

Again,
\[
Loc = R_2.
\]

The first store is completely overwritten by the second and has no observable effect.

\[
\boxed{\text{Option (iv) is correct.}}
\]

\section*{Final Answer}

The replacements that always preserve the program behavior, irrespective of the instructions that follow, are

\[
\boxed{\text{(i) and (iv)}}
\]
Answer:
Position:
Show:

Related questions

82 82 votes
6 answers 6 answers
46.0k
46.0k views
Ishrat Jahan asked Oct 29, 2014
45,950 views
Following table indicates the latencies of operations between the instruction producing the result and instruction using the result.$$\begin{array}{|l|l|c|} \hline \textb...
30 30 votes
3 answers 3 answers
13.2k
13.2k views
Ishrat Jahan asked Oct 29, 2014
13,172 views
Consider a Direct Mapped Cache with 8 cache blocks (numbered $0-7$). If the memory block requests are in the following order$3, 5, 2, 8, 0, 63, 9,16, 20, 17, 25, 18, 30, ...
40 40 votes
2 answers 2 answers
9.4k
9.4k views
Ishrat Jahan asked Oct 29, 2014
9,429 views
The floating point unit of a processor using a design $D$ takes $2t$ cycles compared to $t$ cycles taken by the fixed point unit. There are two more design suggestions $D...
61 61 votes
8 answers 8 answers
22.5k
22.5k views
Ishrat Jahan asked Oct 29, 2014
22,457 views
A processor takes $12$ cycles to complete an instruction I. The corresponding pipelined processor uses $6$ stages with the execution times of $3, 2, 5, 4, 6$ and $2$ cycl...