Explain the commonly used code optimization techniques, Computer Engineering

Assignment Help:

Explain briefly any three of the commonly used code optimization techniques.

1. Common sub expression elimination:

In given expression as "(a+b)-(a+b)/4", in such "common sub-expression" termed to the duplicated "(a+b)". Compilers implementing such technique realize that "(a+b)" would not modify, and by itself, only compute its value once and use similar value next time.

2. Dead code Elimination:

Code which is unreachable or which does not influence the program (for example dead stores) can be removed. In the illustration below, the value assigned to i is never utilized, and the dead store can be removed. The first assignment to global is dead, and the third assignment to global is not reachable; both can be removed.

int global; void f (){ int i;

i = 1;          /* dead store */

global = 1;     /* dead store */

global = 2;

return;

global = 3;     /* unreachable */}

Below is the code fragment after dead code elimination.

int global;

void f (){ global = 2; return;}

3. Loop-invariant code motion

If a quantity is calculated inside a loop during iteration and its value is similar for iteration, this can vastly improve efficiency to hoist this outside the loop and calculate its value just once before the loop begins. It is particularly significant with the address-calculation expressions generated through loops over arrays. For accurate implementation, such technique must be utilized with loop inversion, since not all code is safe to be hoisted outside the loop.

For illustration:

 for (i=1; i≤10, i++){

x=y*2-(1)

.

.

.

}

statement 1 can be hoisted outside the loop assuming value of x and y does not modify in the loop.


Related Discussions:- Explain the commonly used code optimization techniques

Explain the register transfer language, Explain the Register transfer langu...

Explain the Register transfer language Register transfer language means there must be data flow between two registers and logic is in between them for end registers data must f

Presentation of the report, This will be based on presentation of the repor...

This will be based on presentation of the report, complexity of the task, degree of completion and uniqueness of your problem.  As a part of this question, you should also inclu

Design a nand-to-and gate network, Q Use as few gates as possible, design a...

Q Use as few gates as possible, design a NAND-to-AND gate network that realize the following Boolean algebra expression. ABCD + A'BC'D + A'BC'D' + A'BCD + (A'B'C'D' + A'BCD')

#, advantages of dda line algoritm

advantages of dda line algoritm

Explain about floating-executive model, Q. Explain about Floating-Executive...

Q. Explain about Floating-Executive model? Floating-Executive model: The master-slave kernel model is too restrictive in sense that only one of processors viz designated master

Information technology or information system, Information Technology or Inf...

Information Technology or Information System Before going further we need to clarify what we mean by the term information system. It is easy to confuse terminology as many tex

Qwerty-based keyboards, QWERTY-based keyboards In addition the standard...

QWERTY-based keyboards In addition the standard alphabet keys having QWERTY arrangement, a computer keyboard also comprises the control (alt, Del, Ctrl etc. keys) and function

How to changing the directory in dos, Q. How to Changing the Directory in D...

Q. How to Changing the Directory in DOS? You can change the directory. After changing the directory, the new directory becomes the default directory. For example, you change th

What do you mean by internet, Q. What do you mean by Internet? Ans: In...

Q. What do you mean by Internet? Ans: Internet is a network of networks or collection of networks. Several networks such as WAN and LAN connected through suitable hardware an

Differentiate between protection and security, Differentiate between protec...

Differentiate between protection and security. Operating system contains a collection of objects, software or hardware. All objects have a unique name and can be accessed by

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd