12/10/22, 10:08 AM Block Optimization - javatpoint
Home Compiler Data Structure C C++ C# Java SQL HTML CSS JavaScript
https://www.javatpoint.com/optimization-of-basic-blocks 1/8
12/10/22, 10:08 AM Block Optimization - javatpoint
Optimization of Basic Blocks:
Optimization process can be applied on a basic block. While optimization, we don't need to change
the set of expressions computed by the block.
There are two type of basic block optimization. These are as follows:
1. Structure-Preserving Transformations
2. Algebraic Transformations
1. Structure preserving transformations:
The primary Structure-Preserving Transformation on basic blocks is as follows:
Common sub-expression elimination
Dead code elimination
Renaming of temporary variables
Interchange of two independent adjacent statements
(a) Common sub-expression elimination:
In the common sub-expression, you don't need to be computed it over and over again. Instead of
this you can compute it once and kept in store from where it's referenced when encountered again.
a:=b+c
b:=a-d
c:=b+c
d:=a-d
https://www.javatpoint.com/optimization-of-basic-blocks 2/8
12/10/22, 10:08 AM Block Optimization - javatpoint
In the above expression, the second and forth expression computed the same expression. So the
block can be transformed as follows:
a:=b+c
b:=a-d
c:=b+c
d:=b
(b) Dead-code elimination
It is possible that a program contains a large amount of dead code.
This can be caused when once declared and defined once and forget to remove them in this
case they serve no purpose.
Suppose the statement x:= y + z appears in a block and x is dead symbol that means it will
never subsequently used. Then without changing the value of the basic block you can safely
remove this statement.
(c) Renaming temporary variables
A statement t:= b + c can be changed to u:= b + c where t is a temporary variable and u is a new
temporary variable. All the instance of t can be replaced with the u without changing the basic block
value.
(d) Interchange of statement
Suppose a block has the following two adjacent statements:
t1 : = b + c
t2 : = x + y
These two statements can be interchanged without affecting the value of block when value of t1
does not affect the value of t2.
2. Algebraic transformations:
In the algebraic transformation, we can change the set of expression into an algebraically
equivalent set. Thus the expression x:= x + 0 or x:= x *1 can be eliminated from a basic block
without changing the set of expression.
Constant folding is a class of related optimization. Here at compile time, we evaluate
constant expressions and replace the constant expression by their values. Thus the expression
https://www.javatpoint.com/optimization-of-basic-blocks 3/8
12/10/22, 10:08 AM Block Optimization - javatpoint
5*2.7 would be replaced by13.5.
Sometimes the unexpected common sub expression is generated by the relational operators
like <=, >=, <, >, +, = etc.
Sometimes associative expression is applied to expose common sub expression without
changing the basic block value. if the source code has the assignments
a:= b + c
e:= c +d +b
The following intermediate code may be generated:
a:= b + c
t:= c +d
e:= t + b
← Prev Next →
Unleash The Animal 'Flow' - Watch Full Episode
Zee Zest
Sponsored
Youtube For Videos Join Our Youtube Channel: Join Now
Feedback
Help Others, Please Share
https://www.javatpoint.com/optimization-of-basic-blocks 4/8
12/10/22, 10:08 AM Block Optimization - javatpoint
Learn Latest Tutorials
Splunk tutorial SPSS tutorial Swagger T-SQL tutorial
tutorial
Splunk SPSS Transact-SQL
Swagger
Tumblr tutorial React tutorial Regex tutorial Reinforcement
learning tutorial
Tumblr ReactJS Regex
Reinforcement
Learning
R Programming RxJS tutorial React Native Python Design
tutorial tutorial Patterns
RxJS
R Programming React Native Python Design
Patterns
Python Pillow Python Turtle Keras tutorial
tutorial tutorial
Keras
Python Pillow Python Turtle
Preparation
Aptitude Logical Verbal Ability Interview
Reasoning Questions
Aptitude Verbal Ability
Reasoning Interview Questions
https://www.javatpoint.com/optimization-of-basic-blocks 5/8
12/10/22, 10:08 AM Block Optimization - javatpoint
Company
Interview
Questions
Company Questions
Trending Technologies
Artificial AWS Tutorial Selenium Cloud
Intelligence tutorial Computing
AWS
Tutorial tutorial
Selenium
Artificial Cloud Computing
Intelligence
Hadoop tutorial ReactJS Data Science Angular 7
Tutorial Tutorial Tutorial
Hadoop
ReactJS Data Science Angular 7
Blockchain Git Tutorial Machine DevOps
Tutorial Learning Tutorial Tutorial
Git
Blockchain Machine Learning DevOps
With Love For Adam
& Cartier - Watch…
Zee Zest
B.Tech / MCA
DBMS tutorial Data Structures DAA tutorial Operating
tutorial System tutorial
DBMS DAA
Data Structures Operating System
https://www.javatpoint.com/optimization-of-basic-blocks 6/8
12/10/22, 10:08 AM Block Optimization - javatpoint
Computer Compiler Computer Discrete
Network tutorial Design tutorial Organization and Mathematics
Architecture Tutorial
Computer Network Compiler Design
Computer Discrete
Organization Mathematics
Ethical Hacking Computer Software html tutorial
Tutorial Graphics Tutorial Engineering
Web Technology
Tutorial
Ethical Hacking Computer Graphics
Software
Engineering
Cyber Security Automata C Language C++ tutorial
tutorial Tutorial tutorial
C++
Cyber Security Automata C Programming
Java tutorial .Net Python tutorial List of
Framework Programs
Java Python
tutorial
Programs
.Net
Control Data Mining Data
Systems tutorial Tutorial Warehouse
Tutorial
Control System Data Mining
Data Warehouse
https://www.javatpoint.com/optimization-of-basic-blocks 7/8
12/10/22, 10:08 AM Block Optimization - javatpoint
https://www.javatpoint.com/optimization-of-basic-blocks 8/8