Do temp variables slow down my program?

前端 未结 5 847
悲&欢浪女
悲&欢浪女 2020-11-28 08:42

Suppose I have the following C code:

int i = 5;
int j = 10;
int result = i + j;

If I\'m looping over this many times, would it be faster to

5条回答
  •  醉梦人生
    2020-11-28 08:54

    This is an easy task to optimize for an optimizing compiler. It will delete all variables and replace result with 15.

    Constant folding in SSA form is pretty much the most basic optimization there is.

提交回复
热议问题