wiz-icon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

consider the basic block B.
q = 3
r = 10
s = q + r
t = 2 * r + s
t = q
u = q + r
v = q + t
w = 3 + x
Now consider the following basic block B2.
q = 3
r = 10
s = q + r
t = q
u = q + r
v = q + t
w = 3 + x

State which optimization was performed on the basic block B to get B2.

A
Dead code elimination
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
B
Copy photograph
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
Constant propagation/folding
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
Common sub-expression elimination
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution

The correct option is A Dead code elimination
Dead code elimination is a compiler optimization to remove code which does not affect the program results. Removing such code has several benefits: it shrinks program size, an important consideration in some contexts and it allows the running program to avoid executing Irrelevant operations, which reduces its running time. It can also enable further optimizations by simplifying program structure. Dead code includes code that can never be executed (unreachable code) and code that only affects dead variables (written to, but never read again), that is, irrelevant to the program. In basic block B, we can replace t = 2×r+s is a dead code because t is assigned q in the very next statement making t = 2 x r + s irrelevant to the program.

flag
Suggest Corrections
thumbs-up
0
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Elementary Transformation of Matrices
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon