User:Realazthat/Projects wishlist/LLVM/Tactical optimizations: Difference between revisions

no edit summary
(Created page with "These are constant time optimizations; they only increase the program's execution speed by a constant. Almost all optimizations fit into this category. == Branching == <lang llv...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 47:
</lang>
In the above code, LLVM will allocate the two integers a, b, and after each function call reload then from the stack into registers for comparison, even after the printf calls, where the integers are passed by value.
 
== Recursive to iterative functions ==
Automatically convert recursive functions to iterative with a stack
 
=== Eliminate the stack ===
Eliminate the stack where only the top is used (example of dynamic programming)
 
=== Reorder conditional branches ===
Reorder if-else statements/switches to have the most likely condition first to avoid checking all of the conditions.
 
* Determine the likelihood of a condition
* Determine how often a condition will be true if its deterministic