Will my compiler ignore useless code?

前端 未结 9 1520
情深已故
情深已故 2021-02-06 21:53

I\'ve been through a few questions over the network about this subject but I didn\'t find any answer for my question, or it\'s for another language or it doesn\'t answer totally

9条回答
  •  忘掉有多难
    2021-02-06 22:13

    The JIT is basically capable of removing dead code. It is not very thorough. Dead variables and expressions are reliably killed. That is an easy optimization in SSA form.

    Not sure about control flow. If you nest two loops only the inner one will be deleted I remember.

    If you want to find out for sure what is deleted and what not look at the generated x86 code. The C# compiler does very few optimizations. The JIT does a few.

    The 4.5 32 and 64 bit JITs are different code bases and have different behavior. A new JIT (RyuJIT) is upcoming that in my testing generally does worse, sometimes better.

提交回复
热议问题