Register Assignment is considered a very important optimization, because it can
ID: 3770495 • Letter: R
Question
Register Assignment is considered a very important optimization, because it can lead to significant execution time savings relative to other optimizations. Why is this the case?
Please explain why you chose your answer, and please no not copy/paste from elsewhere. I will upvote if correct.
(a) Register assignment reduces the number of registers required for a program, and thus saves time because fewer registers are needed.
(b) By storing values in registers instead of memory, register assignment makes it possible to remove many loads and stores.
(c) Register assignment is necessary because arithmetic can only be done in registers.
(d) Good register assignment leads to better cache behavior.
(e) Nobody really knows.
Explanation / Answer
(a) Register assignment reduces the number of registers required for a program, and thus saves time because fewer registers are needed.
Reason - If an expression is carried out both when a condition is met and is not met, it can be written just once outside of the conditional statement. Similarly, if certain types of expressions appear inside a loop, they can be moved out of it because their effect will be the same no matter if they're executed many times or just once. Also known as total redundancy elimination.
These optimizations are intended to be done after transforming the program into a special form called static single assignment, in which every variable is assigned in only one place. Although some function without SSA, they are most effective with SSA. Many optimizations listed in other sections also benefit with no special changes, such as register allocation.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.