Code Generation & Register Allocation



Answer & solution
Answer: 2 registers and 6 input reads, excluding final result storage (no official key was published)
Assume six independent input values initially reside in memory, arithmetic allows a memory source and register destination, and exponentiation is an available operation. Read e into R1 and compute R1:=R1**f; read d into R2 and compute R2:=R2/R1. Reuse R1 for a, then add b and multiply by c; finish R1:=R1−R2. Each of a, b, c, d, e, f is read once, achieving the six-read lower bound. Two registers retain one partial result while forming the other; one register would require a spill or destructive memory temporary and extra traffic. A required final output store adds one access; instruction fetches are not operand accesses.