Code Generation (#')! *+%,-,.)" !"#$%! &$' (#')! 20"3)% +"#3"0- /)$)"0%#"

Similar documents
CODE GENERATION Monday, May 31, 2010

Optimization. ASU Textbook Chapter 9. Tsan-sheng Hsu.

CSE 504: Compiler Design. Code Generation

G Compiler Construction Lecture 12: Code Generation I. Mohamed Zahran (aka Z)

Compiler Optimization Techniques

CSE443 Compilers. Dr. Carl Alphonce 343 Davis Hall

Compiler Theory. (Intermediate Code Generation Abstract S yntax + 3 Address Code)

Principles of Compiler Design

CSE443 Compilers. Dr. Carl Alphonce 343 Davis Hall

UNIT-V. Symbol Table & Run-Time Environments Symbol Table

Figure 28.1 Position of the Code generator

General issues. Section 9.1. Compiler Construction: Code Generation p. 1/18

Intermediate Representations

CSE 401/M501 Compilers

Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2)

PSD3A Principles of Compiler Design Unit : I-V. PSD3A- Principles of Compiler Design

Compiler Optimization and Code Generation

Lecture 2: The Art of Emulation

CSE P 501 Compilers. Intermediate Representations Hal Perkins Spring UW CSE P 501 Spring 2018 G-1

Compiler Architecture

Basic Processor Design

CSC D70: Compiler Optimization

Lectures 3-4: MIPS instructions

Lecture 4: MIPS Instruction Set

Code Generation. CS 540 George Mason University

Code Generation. M.B.Chandak Lecture notes on Language Processing

The MIPS Instruction Set Architecture

Principles of Compiler Design

Chapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont )

Compilation /17a Lecture 10. Register Allocation Noam Rinetzky

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Intermediate Representations

ECE232: Hardware Organization and Design

CPU Architecture and Instruction Sets Chapter 1

CPSC 213, Winter 2009, Term 2 Midterm Exam Date: March 12, 2010; Instructor: Mike Feeley

Lecture 4: Instruction Set Architecture

Architectures. Code Generation Issues III. Code Generation Issues II. Machine Architectures I

Intermediate Representation (IR)

Low-level optimization

CS415 Compilers. Intermediate Represeation & Code Generation

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary

Control Instructions

ECE232: Hardware Organization and Design. Computer Organization - Previously covered

More Code Generation and Optimization. Pat Morin COMP 3002

Intermediate Code Generation

CPSC 213. Introduction to Computer Systems. Static Control Flow. Unit 1d

Course Administration

Three address representation

Instructions: Language of the Computer

Instructions: Language of the Computer

NET3001. Advanced Assembly

CSc 453. Compilers and Systems Software. 21 : Code Generation II. Department of Computer Science University of Arizona

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture

CPSC 213. Introduction to Computer Systems. Static Control Flow. Unit 1d

Architecture II. Computer Systems Laboratory Sungkyunkwan University

Assembly Language Programming. CPSC 252 Computer Organization Ellen Walker, Hiram College

Instruction Set Architecture. "Speaking with the computer"

CSCE 5610: Computer Architecture

Compilers. Intermediate representations and code generation. Yannis Smaragdakis, U. Athens (original slides by Sam

COSC 6385 Computer Architecture. Instruction Set Architectures

Intermediate Representations & Symbol Tables

Operands and Addressing Modes

Instruction Sets Ch 9-10

Instruction Sets Ch 9-10

tokens parser 1. postfix notation, 2. graphical representation (such as syntax tree or dag), 3. three address code

Stored Program Concept. Instructions: Characteristics of Instruction Set. Architecture Specification. Example of multiple operands

A Processor. Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3

Topic Notes: MIPS Instruction Set Architecture

18. Machine Language. Computer Systems. COMP1917: Computing 1. Machine Language Programming. History of Computer Technology

Machine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine

CPSC 213. Introduction to Computer Systems. Reading. Control Flow. Loops (S5-loop) Static Control Flow. Unit 1d. Companion.

Prof. Kavita Bala and Prof. Hakim Weatherspoon CS 3410, Spring 2014 Computer Science Cornell University. See P&H 2.8 and 2.12, and A.

CSc 453 Interpreters & Interpretation

Computer Architecture

Lecture 20: AVR Programming, Continued. AVR Program Visible State (ones we care about for now)

Lecture 5: Procedure Calls

Group B Assignment 9. Code generation using DAG. Title of Assignment: Problem Definition: Code generation using DAG / labeled tree.

Code Generation. Frédéric Haziza Spring Department of Computer Systems Uppsala University

Introduction to Digital Logic

Compiling Techniques

Instruction Set Architecture (Contd)

Lecture 3 Local Optimizations, Intro to SSA

CPSC 213. Introduction to Computer Systems. Readings for Next 2 Lectures. Loops (S5-loop) Control Flow. Static Control Flow. Unit 1d.

Instructions: Assembly Language

Instruction Set. Instruction Sets Ch Instruction Representation. Machine Instruction. Instruction Set Design (5) Operation types

CSc 453. Code Generation I Christian Collberg. Compiler Phases. Code Generation Issues. Slide Compilers and Systems Software.

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization

Advanced Computer Architecture-CS501. Vincent P. Heuring&Harry F. Jordan Chapter 2 Computer Systems Design and Architecture

CSE443 Compilers. Dr. Carl Alphonce 343 Davis Hall

Introduction. CSc 453. Compilers and Systems Software. 19 : Code Generation I. Department of Computer Science University of Arizona.

EC-801 Advanced Computer Architecture

RTN (Register Transfer Notation)

Code Generation. The Main Idea of Today s Lecture. We can emit stack-machine-style code for expressions via recursion. Lecture Outline.

Chapter 2 Instructions Sets. Hsung-Pin Chang Department of Computer Science National ChungHsing University

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

We can emit stack-machine-style code for expressions via recursion

SISTEMI EMBEDDED. Computer Organization Central Processing Unit (CPU) Federico Baronti Last version:

Intermediate Representations

Computer Architecture 2/26/01 Lecture #

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1

Transcription:

Code Generation!"#$%! &$' 1$%)"-)',0%)! (#')! (#')! *+%,-,.)" 1$%)"-)',0%)! (#')! (#')! /)$)"0%#" 20"3)% +"#3"0-

Memory Management returned value actual parameters commonly placed in registers (when possible) optional control link optional access link saved machine status local data temporaries A.R. Static Heap Free Memory Stack For some compiler, the intermediate code is a pseudo-code of a virtual machine. Interpreter of the virtual machine is invoked to execute the intermediate. No machine-dependent generation is needed. Usually with great overhead. Examples:! Pascal: P-code for the virtual P machine.! JAVA: Bytecode for the virtual JAVA machine.

Machine-dependent issues! Input and output formats: - The formats of the intermediate and the target program.! Memory management: - Alignment, indirect addressing, paging, segment,... - Those you learned from your assembly language class.! Instruction cost: - Special machine instructions to speed up execution. - Example: Increment by 1. Multiplying or dividing by 2. Bit-wise manipulation. Operators applied on a continuous block of memory space. - Pick a fastest instruction combination for a certain target machine. Machine-dependent issues Register allocation: in-between machine dependent and independent issues.! C language allows the user to management a pool of registers.! Some language leaves the task to compiler.! Idea: save mostly used intermediate result in a register. However, finding an optimal solution for using a limited set of registers is NP-hard. t=a+b load R0,a load R1,b add R0,R1 store R0,T load R0,a add! R0,b store R0,T

Machine-independent issues Techniques - Analysis of dependence graphs. - Analysis of basic blocks and flow graphs. - Semantics-preserving transformations. - Algebraic transformations.!"#$!%&'#($)&*'&%+$,-./$0&#123#1$456(&237*5$6#($3*+82(#&9 :%5;$&#'46(#&6<$("&##$%11&#66$456(&237*56<$64+8=#$$%11&#6645'$+*1#6<$ 64+8=#$456(&237*5$6#($%&3" /-./$03*+8=#>$456(&237*5$6#($3*+82(#&9$?#@$&#'46(#&6<$(@*$ %11&#66$456(&237*56<$A%&4*26$ %11&#6645'$+*1#6<$A%&4%B=#$=#5'("$456(&237*5$6#(.(%3C$B%6#1$:%3"45# )26"45'$*8#&%516$*5(*$%$6(%3C$ D=+*6($146%88#%&#1<$("#5$&#A4A#1$@4("$E%A%$F4&(2%=$$:%3"45#$0EF:9

Machine-dependent issues Choice of the target language: RISC LD R0, y //R0 = y ADD R0, R1, R2 //R0 = R0=R1+R2 ST x, R0 // x = R0 A Simple Target Machine Model Byte-addressable machine with n general-purpose registers, R0, R1,...,Rn - 1 OPERATIONS FORMAT Load Store Computation Unconditional jumps LD r,x (r=x) ST x,r (x=r) OP r1, r2,r3 (SUB r1, r2,r3 // r1=r2-r3) BR L Conditional jump Bcond r, L (BLTZ r, L)

Addressing modes format addr examples x Lval(x) name a(r) Lval(a)+ Rval(r) LD R1 a(r2) const(r) const+rval(r) LD R1, 100(R2) *r Rval(Rval(r)) LD R1, *(R2) *const(r) Rval(const+Rval(r)) LD R1, *100(R2) #const // immediate op nil LD R1, #100 x = y-z LD R1, y LD R2, z SUB R1,R1,R2 ST x, R1 b = a[i] LD R1, i MUL R1,R1,8 LD R2,a(R1) ST b, R2 //R2! Rval(Lval(a)+Rval(R1))

a[j] = c LD R1, c LD R2, j MUL R2, R2, 8 ST a(r2), R1 x = *i LD R1, i LD R2,0(R1) ST b, R2 *p = y LD R1, p LD R2, y ST 0(R1),R2 if x < y goto L LD R1, x LD R2, y SUB R1, R1, R2 BLTZ R1, M M is the label that represents the first machine instruction generated from the three-address instruction that has label L

Register allocation: in-between machine dependent and independent issues. C language allows the user to management a pool of registers. Some language leaves the task to compiler. Idea: save mostly used intermediate result in a register. Finding an optimal solution for using a limited set of registers is NP-hard. t=a+b load R0,a load!r1,b add R0,R1 store R0,T Basic blocks Maximal sequences of consecutive three-address instructions s.t.: The flow of control can only enter the basic block through the first instruction in the block (no jumps into the middle of the block) Control will leave the block without halting or branching, except possibly at the last instruction in the block. Partition the intermediate code into basic blocks The basic blocks become the nodes of a flow graph, whose edges indicate which blocks can follow which other blocks.

Partitioning three-address instructions into basic blocks. Algorithm 8.5: INPUT: A sequence of three-address instructions. OUTPUT: A list of the basic blocks for that sequence in which each instruction is assigned to exactly one basic block. METHOD: a) determine the leaders: 1. The first three-address instruction in the intermediate is a leader. 2. Any instruction that is the target of a conditional or unconditional jump! is a leader. 3. Any instruction that immediately follows a conditional or unconditional jump is a leader. b) for each leader, its basic block consists of itself and all instructions up to but not including the next leader or the end of the intermediate program. 1) i = 1 2) j = 1 3) t1 = 10 * i 4) t2 = t1 + j 5) t3 = 8 * t2 6) t4 = t3-88 7) a[t4] = 0.0 8) j = j + 1 9) if j <= 10 goto (3) 10) i = i + 1 11) if i <= 10 goto (2) 12) i = 1 13) t5 = i - 1 14) t6 = 88 * t5 15) a [t6] = 1.0 16) i = i + 1 17) if i <= 10 goto (13) Leaders?

1) i = 1 2) j = 1 3) t1 = 10 * i 4) t2 = t1 + j 5) t3 = 8 * t2 6) t4 = t3-88 7) a[t4] = 0.0 8) j = j + 1 9) if j <= 10 goto (3) 10) i = i + 1 11) if i <= 10 goto (2) 12) i = 1 13) t5 = i - 1 14) t6 = 88 * t5 15) a [t6] = 1.0 16) i = i + 1 17) if i <= 10 goto (13) 1) i = 1 1) i = 1 2) j = 1 3) t1 = 10 * i 4) t2 = t1 + j 5) t3 = 8 * t2 6) t4 = t3-88 7) a[t4] = 0.0 8) j = j + 1 9) if j <= 10 goto (3) 10) i = i + 1 11) if i <= 10 goto (2) 12) i = 1 13) t5 = i - 1 14) t6 = 88 * t5 15) a [t6] = 1.0 16) i = i + 1 17) if i <= 10 goto (13) 2) j = 1 3) t1 = 10 * i 4) t2 = t1 + j 5) t3 = 8 * t2 6) t4 = t3-88 7) a[t4] = 0.0 8) j = j + 1 9) if j <= 10 goto (3) 10) i = i + 1 11) if i <= 10 goto (2) 12) i = 1 13) t5 = i - 1 14) t6 = 88 * t5 15) a [t6] = 1.0 16) i = i + 1 17) if i <= 10 goto (13)

1) i = 1 2) j = 1 3) t1 = 10 * i 4) t2 = t1 + j 5) t3 = 8 * t2 6) t4 = t3-88 7) a[t4] = 0.0 8) j = j + 1 9) if j <= 10 goto (3) 10) i = i + 1 11) if i <= 10 goto (2) 12) i = 1 13) t5 = i - 1 14) t6 = 88 * t5 15) a [t6] = 1.0 16) i = i + 1 17) if i <= 10 goto (13) B3 B4 B6 B1 B2 i = 1 j = 1 t1 = 10 * i t2 = t1 + j t3 = 8 * t2 t4 = t3-88 a[t4] = 0.0 j = j + 1 if j <= 10 goto B3 i = i + 1 if i <= 10 goto B2 B5 i = 1 t5 = i - 1 t6 = 88 * t5 a [t6] = 1.0 i = i + 1 if i <= 10 goto B6 1) i = 1 2) j = 1 3) t1 = 10 * i 4) t2 = t1 + j 5) t3 = 8 * t2 6) t4 = t3-88 7) a[t4] = 0.0 8) j = j + 1 9) if j <= 10 goto (3) 10) i = i + 1 11) if i <= 10 goto (2) 12) i = 1 13) t5 = i - 1 14) t6 = 88 * t5 15) a [t6] = 1.0 16) i = i + 1 17) if i <= 10 goto (13) B3 B4 B6 B1 B2 i = 1 j = 1 t1 = 10 * i t2 = t1 + j t3 = 8 * t2 t4 = t3-88 a[t4] = 0.0 j = j + 1 if j <= 10 goto B3 i = i + 1 if i <= 10 goto B2 B5 i = 1 t5 = i - 1 t6 = 88 * t5 a [t6] = 1.0 i = i + 1 if i <= 10 goto B6

Optimization of Basic Blocks " Local optimization within each basic block " Global optimization We will focus on the former. DAG Representation of Basic Blocks Target: Construct a DAG for a basic block 1. There is a node in the DAG for each of the initial values of the variables appearing in the basic block. 2.!statement s we associate a node Ns. The children of Ns are those nodes corresponding to statements that are the last definitions, prior to s, of the operands used by s. 3. each node Ns is labeled by the operator applied at s. Attached to Ns is the list of variables for which it is the last definition within the block. 4. Certain nodes are designated output nodes. These are the nodes whose variables are live on exit from the block; that is, their values may be used later, in another block of the flow graph.

)!/!0!.!+ 0!/!)!1 2 +!/!0!.!+ 2!/!)!" 2. ) " 032. 2 4 + 0 4 + 4 When we construct the node for the third statement c=b+c, we know that the use of b in b+c refers to the node labeled -, because that is the most recent definition of b. Thus, we do not confuse the values computed at statements one and three. However, the node corresponding to the fourth statement d=a-d has the operator - and the nodes with attached variables a and d0 as children. Since the operator and the children are the same as those for the node corresponding to statement two, we do not create this node, but add d to the list of definitions for the node labeled The DAG representation of a basic block lets us perform local common sub-expressions elimination dead code elimination reordering of statements that do not depend on one another reordering of operands of three-address instructions by applying algebraic laws

D$.4+8=#$/*1#$G#5#&%(*& G#5#&%(#$3*1#$?*&$%$645'=#$B%643$B=*3C$ H*@$(*$26#$&#'46(#&6I -5$+*6($+%3"45#$%&3"4(#3(2&#6<$6*+#$*&$%==$*?$("#$$*8#&%516$ +26($B#$45$&#'46(#&6,#'46(#&6$+%C#$'**1$(#+8*&%&4#6$ H*=1$A%=2#6$("%($%&#$3*+82(#1$45$*5#$B%643$B=*3C$ %51$26#1$45$*("#&$B=*3C6 $ JK#5$26#1$@4("$&25$7+#$6(*&%'#$+%5%'#+#5( These are competing needs, since the number of registers available is limited. LD reg, mem ST mem, reg OP reg, reg, reg,#'46(#&$%51$d11&#66$l#63&48(*&6 M*&$#%3"$%A%4=%B=#$&#'46(#&<$%$&#'46(#&$$1#63&48(*&$ 0,L9$C##86$(&%3C$*?$("#$A%&6$@"*6#$$32&&#5($A%=2#$45$ ("%($&#'46(#& -547%==;$#+8(; M*&$#%3"$A%&<$%5$%11&#66$1#63&48(*&$0DL9$C##86$$ (&%3C$*?$("#$=*3%7*56$@"#&#$("#$32&&#5($A%=2#$$*?$ ("#$A%&$3%5$B#$?*251 N*3%7*5$3%5$B#$%$&#'46(#&<$%$+#+*&;$%11&#66<$#(3O$

Generation Algorithm For a three address instruction, e.g. x=y+z, do: Use getreg(x=y+z) to select registers Rx, Ry, Rz for x, y, z If y is not in Ry, issue an instruction LD Ry,y' (y' is a location for y) Similarly for z Issue the instruction ADD Rx,Ry,Rz Copy statement x=y We assume that getreg() will always choose the same register for both x and y If y is not already in register, generate LD Ry,y' (y' is a location for y) Adjust RD for Ry so it includes x change the AD for x so that its only location is Ry Ending the basic block for each variable x whose location descriptor does not say that its value is located in the memory location for x and if x is used at other blocks, issue ST x,r (R is a register in which x's value exists at the end of the block)!"#"$%#$&'($%)*(+&"#,&-,,+())&.()/+%0*1+)&2'.&"#,&-.3 M*&$NL$,<$>$ /"%5'#$,L$?*&$,$6*$4($"*=16$*5=;$> /"%5'#$DL$?*&$>$B;$%1145'$,$%6$%5$%1147*5%=$=*3%7*5 M*&$.!$><$,$ /"%5'#$DL$?*&$>$(*$453=21#$4(6$*@5$+#+*&;$=*3%7*5 M*&$DLL$,><$,;<$,P$ /"%5'#$,L$?*&$,>$$6*$4($"*=16$*5=;$> /"%5'#$DL$?*&$>$6*$4(6$*5=;$=*3%7*5$46$,>$,#+*A#$,>$?&*+$("#$DL$*?$%5;$A%&$*("#&$("%5$> M*&$$>Q$;, after generating the load for y into register Ry, if needed, and after managing descriptors as for all load statements: Add x to the register descriptor for Ry. Change the address descriptor for x so that its only location is Ry.

!"#$%&' (!)!#!*+,!)!#!* -.!)!(!/!, #!)!0 0!)!.!/!, (1!,1!.!#2'!('$%!.#231!456&'!#1!+1!-1!0!#2'!7&8+#& 933,$'!2'763('23!#2'!':8,75 6( ;',3'!2'763('23!45':'.'2!%8336+&' For a three address instruction, e.g. x=y+z, do: Use getreg(x=y+z) to select registers Rx, Ry, Rz for x, y, z If y is not in Ry, issue an instruction LD Ry,y' (y' is a location for y) Similarly for z Issue the instruction ADD Rx,Ry,Rz Copy statement x=y We assume that getreg() will always choose the same register for both x an y If y is not already in register, generate LD Ry,y' (y' is a location for y) Adjust RD for Ry so it includes x change the AD for x so that it only location is Ry Ending the basic block for each variable x whose location descriptor does not say that its value is located in the memory location for x and if x is used at other blocks, issue ST x, R (R is a register in which x's value exists at the end of the block) For LD R, x Change RD for R so it holds only x Change AD for x by adding R as an additional location For ST x, R Change AD for x to include its own memory location For ADD Rx, Ry, Rz Change RD for Rx so it holds only x Change AD for x so its only location is Rx Remove Rx from the AD of any var other than x For x= y, after generating the load for y into register Ry, if needed, and after managing descriptors as for all load statements: Add x to the register descriptor for Ry. Change the address descriptor for x so that its only location is Ry. 0!8!#!" ( 1!8!#!" )!"#$%&'! +, +- +. # ( ) * 0 1 / # ( ) * 23!+,9!#4!23!+-9!(4!567!+-9!+,9!+- +- +- +- +, +- +. # ( ) * 0 1 / # 0 #9+, ( ) * +- 23!+.9!)4!!567!+,9!+,9!+. +, +- +. # ( ) * 0 1 / 1 0 ) # ( )9+. * +- +,

For a three address instruction, e.g. x=y+z, do: Use getreg(x=y+z) to select registers Rx, Ry, Rz for x, y, z If y is not in Ry, issue an instruction LD Ry,y' (y' is a location for y) Similarly for z Issue the instruction ADD Rx,Ry,Rz Copy statement x=y We assume that getreg() will always choose the same register for both x an y If y is not already in register, generate LD Ry,y' (y' is a location for y) Adjust RD for Ry so it includes x change the AD for x so that it only location is Ry Ending the basic block for each variable x whose location descriptor does not say that its value is located in the memory location for x and if x is used at other blocks, issue ST x, R (R is a register in which x's value exists at the end of the block) For LD R, x Change RD for R so it holds only x Change AD for x by adding R as an additional location For ST x, R Change AD for x to include its own memory location For ADD Rx, Ry, Rz Change RD for Rx so it holds only x Change AD for x so its only location is Rx Remove Rx from the AD of any var other than x For x= y, after generating the load for y into register Ry, if needed, and after managing descriptors as for all load statements: Add x to the register descriptor for Ry. Change the address descriptor for x so that its only location is Ry. )!*!!!+!,! "##!$%&!$'&!$( -!*!0 $( $' $% -. / 0!, ),! ) -. / 0 $' $( $% 1#!$'&!0 $( $' $% -. / 0!, ), -&0 ) $'. / 0&$' $( $% For a three address instruction, e.g. x=y+z, do: Use getreg(x=y+z) to select registers Rx, Ry, Rz for x, y, z If y is not in Ry, issue an instruction LD Ry,y' (y' is a location for y) Similarly for z Issue the instruction ADD Rx,Ry,Rz Copy statement x=y We assume that getreg() will always choose the same register for both x an y If y is not already in register, generate LD Ry,y' (y' is a location for y) Adjust RD for Ry so it includes x Ending the basic block for each variable x whose location descriptor does not say that its value is located in the memory location for x and if x is used at other blocks, issue ST x, R (R is a register in which x's value exists at the end of the block) For LD R, x Change RD for R so it holds only x Change AD for x by adding R as an additional location For ST x, R Change AD for x to include its own memory location For ADD Rx, Ry, Rz Change RD for Rx so it holds only x Change AD for x so its only location is Rx Remove Rx from the AD of any var other than x For x= y, after generating the load for y into register Ry, if needed, and after managing descriptors as for all load statements: Add x to the register descriptor for Ry. Change the address descriptor for x so that its only location is Ry. &!'!(!)!*!""!#$+!#%+!#$ #% #$ #, #% -. / & 0 * ( & - ( #,. / #$ #% 12!-+!#,3!12!&+!#$ #$ #, #% -. / & 0 * ( & - ( -+#,. / &+#$ #%

getreg(i): selects registers for each memory location associated with the three-address instruction I 45#/61#&$(*'($23 /*5641#&$843C45'$,;$?*&$;$45$>$Q$;$R$P -?$;$46$45$%$&#'46(#&<$1*$5*("45' -?$;$46$5*($45$%$&#'46(#&$%51$("#&#$46$%$#+8(;$*5#<$$3"**6#$4($%6$,; ),JSNT:U$;$46$5*($45$%$&#'46(#&<$%51$("#&#$%&#$5*$#+8(;$&#'46(#&6 @#$8&*3##1$45$("#$?*==*@45'$@%;U N#($A$B#$*5#$*?$("#$A%&$45$,$$ V#$%&#$JW$4?$A$46$6*+#@"#&#$#=6#$B#641#6$,$ V#$%&#$JW$4?$A$46$> V#$%&#$JW$4?$A$46$5*($26#1$=%(#&$ if we are not OK perform 70%889&#":(8;&$.!$A<$,

Selection of the register Rx. The issues and options are almost as for y, so we shall only mention the differences. - Since a new value of x is being computed, a register that holds only x is always an acceptable choice for Rx. This statement holds even if x is one of y and z, since our machine instructions allows two registers to be the same in one instruction. - If y is not used after instruction I and Ry holds only y after being loaded, if necessary, and, if y is not a temporary, AD(y) contains y, then Ry can also be used as Rx. A similar option holds regarding z and Rz. - Case when I is a copy instruction x = y. We pick the register Ry as above. Then, we always choose Rx = Ry.