diff --git a/textbook/07-optimization.md b/textbook/07-optimization.md index d6de14b..4378ea0 100644 --- a/textbook/07-optimization.md +++ b/textbook/07-optimization.md @@ -1,4 +1,3 @@ - \pagebreak #### Many Optimizations Are NP-Complete #### What is the Target Architecture? ##### The Machine Doing the Compilation - + ##### Factors - ###### CPU Speed ###### Release vs Debugging +Example: + Take the instruction set: + a = b + c; + d = a + e; + + What is actually implemented in machine code is: + MOV b, R0 + ADD c, R0 + MOV R0, a + MOV a, R0 + ADD e, R0 + MOV R0,d + +This machine can be optimised. + + It can be condensed to: + MOV b, R0 + ADD c, R0 + MOV R0, a + ADD e, R0 + MOV R0, d + +By taking the code at its base level and optimising it there, the code will run much faster and have to execute even less commands to achieve the same result.