Redirected
recategorized
5,140 views
2 votes
2 votes

In compiler optimization, operator strength reduction uses mathematical identities to replace slow math operations with faster operations. Which of the following code replacements is an illustration of operator strength reduction ?

  1. Replace $P + P$ by $2 ^{*} P$ or Replace $3 + 4$ by $7$.
  2. Replace $P ^{*} 32$ by $P < < 5$
  3. Replace $P ^{*} 0$ by $0$ 
  4. Replace $(P < <4) - P$ by $P ^{*} 15$
recategorized

5 Answers

3 votes
3 votes

Strength Reduction : Replace expensive operations with less expensive but equivalent operations.

For Example : Multiplication is more expensive operation than addition.

Shift operation is less expensive operation than Multiplication/Division.

2*3 CAN BE REPLACED WITH 2+2+2 . 

OPTION A : We are replacing less expensive operation with more expensive operation which is not right. So Option 1 is incorrect. 

Option B : We are replacing Multiplication (Expensive Operation) With Shift(Less expensive) . So this is OK

Option : C Both are equivalent 

Option D: Replacing shift(Less Expensive) with Multiplication . This is Wrong

Correct Answer for This Question is B.

0 votes
0 votes
i think strength reduction is replacing more costly funtion with less cost funtion /opertor like we can do multiplication with the help of addition which is less costly in terms of circuit .
0 votes
0 votes
A. Replace P + P by 2 * P  => Strength is increased

 Replace 3 + 4 by 7 => Its folding.

C. Replace P * 0 by 0 => Arithmetic Simplification.

D.  Replace (P < <4) – P by P * 15 => Strength increased, as shifting is faster than multiplication.

B. Replace P * 32 by P < < 5 => Strength reduction as shifting is faster than multiplication.

So B is correct.

Related questions

2 votes
2 votes
1 answer
2
makhdoom ghaya asked Sep 8, 2016
3,250 views
Grammar of the programming is checked at ________ phase of compiler.Semantic analysisCode generationSyntax analysisCode optimization
2 votes
2 votes
1 answer
3
makhdoom ghaya asked Sep 28, 2016
2,795 views
In Data mining, ______ is a method of incremental conceptual clustering.STRINGCOBWEBCORBAOLAD
1 votes
1 votes
1 answer
4
makhdoom ghaya asked Sep 28, 2016
2,400 views
Discovery of cross sales opportunities is called as _____.AssociationVisualizationCorrelationSegmentation