Question

List down some code optimization techniques in assembly (at least three) with relevant code examples.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

Branch optimization

Rearranges the program code to minimize branching logic and to combine physically separate blocks of code.

Code motion

If variables used in a computation within a loop are not altered within the loop, the calculation can be performed outside of the loop and the results used within the loop.

Common subexpression elimination

In common expressions, the same value is recalculated in a subsequent expression. The duplicate expression can be eliminated by using the previous value.

Constant propagation

Constants used in an expression are combined, and new ones are generated. Some implicit conversions between integers and floating-point types are done.

Dead code elimination

Eliminates code that cannot be reached or where the results are not subsequently used.

Dead store elimination

Eliminates stores when the value stored is never referenced again. For example, if two stores to the same location have no intervening load, the first store is unnecessary and is removed.

Global register allocation

Allocates variables and expressions to available hardware registers using a "graph coloring" algorithm.

Inlining

Replaces function calls with actual program code

Instruction scheduling

Reorders instructions to minimize execution time

Interprocedural analysis

Uncovers relationships across function calls, and eliminates loads, stores, and computations that cannot be eliminated with more straightforward optimizations.

Invariant IF code floating (Unswitching)

Removes invariant branching code from loops to make more opportunity for other optimizations.

Reassociation

Rearranges the sequence of calculations in an array subscript expression, producing more candidates for common expression elimination.

Store motion

Moves store instructions out of loops.

Strength Reduction

Replaces less efficient instructions with more efficient ones. For example, in array subscripting, an add instruction replaces a multiply instruction.

Value numbering

Involves constant propagation, expression elimination, and folding of several instructions into a single instruction.

Add a comment
Know the answer?
Add Answer to:
List down some code optimization techniques in assembly (at least three) with relevant code examples.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT