1 1 vote Consider the following three-address code sequence used for a loop:i = 0 L1: t1 = i * 4 t2 = base + t1 val = load t2 i = i + 1 if i < 100 goto L1Which optimization technique would most effectively transform this code to reduce the number of multiplications inside the loop, and what would be the resulting change to line $2$?Constant Folding; $\verb|t1 = 0|$ Dead Code Elimination; Line $2$ is removed entirely. Strength Reduction; $\verb|t1 = t1 + 4|$ (with initialization $\verb|t1 = 0|$ before the loop). Loop Unrolling; The loop body is copied $100$ times to remove the branch. Compiler Design goclasses compiler goclasses-cs-dpp goclasses-cs-dpp-day-183 goclasses-compiler-practice-questions + – GO Classes 262 views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
0 0 votes Strength Reduction replaces a "heavy" operation like multiplication inside a loop with a "lighter" one like addition. By initializing $\verb|t1|$ to $0$ and adding $4$ in each iteration, the compiler eliminates the costly $\verb|i*4|$ calculation. GO Classes answered Jan 23 GO Classes comment Share Follow 0 reply Please log in or register to add a comment.