common subexpression elimination and copy propagation in titanium
DESCRIPTION
Common Subexpression Elimination and Copy Propagation in Titanium. Johnathon Jamison David Marin CS265 S. Graham. Global Copy Propagation. Given a = b; … x = a + 1; We want to replace a with b on the last line, but we need to know that a and b are unchanged - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/1.jpg)
Common Subexpression Elimination and Copy
Propagation in TitaniumJohnathon Jamison
David Marin
CS265
S. Graham
![Page 2: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/2.jpg)
![Page 3: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/3.jpg)
![Page 4: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/4.jpg)
![Page 5: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/5.jpg)
![Page 6: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/6.jpg)
![Page 7: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/7.jpg)
Global Copy Propagation
• Given
a = b;
…
x = a + 1;
• We want to replace a with b on the last line, but we need to know that a and b are unchanged
• Def/use analysis isn’t quite enough (why?)
![Page 8: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/8.jpg)
Inserting Fake Defs and Uses
• Add fake defs and uses so that def/use analysis gives us the info we need
b = b;
a = b;
…
newtemp = b;
x = a + 1;• We can use this technique to enable CSE too.
![Page 9: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/9.jpg)
![Page 10: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/10.jpg)
![Page 11: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/11.jpg)
![Page 12: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/12.jpg)
![Page 13: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/13.jpg)
![Page 14: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/14.jpg)
![Page 15: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/15.jpg)
![Page 16: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/16.jpg)
![Page 17: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/17.jpg)
![Page 18: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/18.jpg)
![Page 19: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/19.jpg)
Interaction with Copy Propagation
• Any temps introduced are placed after the calculation, so that copy propagation can remove thema = f * i a = f * i
temp_1 = a… …b = f * i b = temp_1
temp_2 = b… …c = f * i c = temp_2
![Page 20: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/20.jpg)
![Page 21: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/21.jpg)
![Page 22: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/22.jpg)
![Page 23: Common Subexpression Elimination and Copy Propagation in Titanium](https://reader036.vdocument.in/reader036/viewer/2022062806/56814f0e550346895dbca1f9/html5/thumbnails/23.jpg)
Local CSE
• Used Muchnick’s algorithm (described in class)
• Used defs to find what was killed
• Fully implemented– Except method calls
• Since we are using defs already, why not so something more substantial?