retagged by
4,927 views

2 Answers

0 votes
0 votes

A.

"In computer programmingloop-invariant code consists of statements or expressions (in an imperative programming language) which can be moved outside the body of a loop without affecting the semantics of the program. Loop-invariant code motion (also called hoisting or scalar promotion) is a compiler optimization which performs this movement automatically."

Source: Wikipedia

0 votes
0 votes
option A and B both are correct.

A. loop invariant computation is one that computes the same value every time a loop is executed.so,moving such a computation outside the loop leads to a reduction in the execution time.

B.Induction variables are those variables used in a loop; their values are in lock-step, and hence, it may be possible to eliminate all except one.

for Ex:

Before Elimination of induction variables

int Y[SIZE];
int Z[SIZE];
void fun (void)
{
  int x1, x2, x3;

  for (x1 = 0, x2 = 0, x3 = 0; x1 < SIZE; x1++)
    Y[x2++] = Z[x3++];
  return;
}

After Elimination of induction variables

int Y[SIZE];
int Z[SIZE];
void fun (void)
{
  int x1;

  for (x1 = 0; x1 < SIZE; x1++)
    Y[x1++] = Z[x1++];
  return;
}

Related questions

4 votes
4 votes
1 answer
1
Tendua asked Dec 21, 2016
2,938 views
How to find unnecessary production while optimising DAG. for ex-a = b * c d = b e = d * c b = e f = b + c g = f + dHow many production need to be removed and how to find ...
0 votes
0 votes
1 answer
2
0 votes
0 votes
1 answer
3
0 votes
0 votes
1 answer
4
garimanand asked Sep 28, 2018
299 views
what is the usage of symbol table in code optimization phase please explain???