r/Compilers • u/BrainThinkerMan • 24d ago
Compilers add or remove perfomace?
isnt it that compilers change the code, as in not only transferring it into machine language, but before that changing the structure of the code. so how would one attempt to make performant code if the compiler changes sed code that i tried to make performant?
2
Upvotes
View all comments
8
u/Big_Tadpole7174 24d ago
Most compilers perform compilation in these steps:
Step 4 is usually where the bulk of the optimization takes place. You can rearrange AST nodes, remove unused nodes, etc. So it's not so much that the machine code is optimized (though it can in step 6) but that the tree that is used to generate code is altered. Hope this helps.