An expensive jump with GCC 5.4.0

后端 未结 4 886
一向
一向 2020-12-07 15:21

I had a function which looked like this (showing only the important part):

double CompareShifted(const std::vector& l, const std::vector&         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-07 15:43

    This might be because when you are using the logical operator && the compiler has to check two conditions for the if statement to succeed. However in the second case since you are implicitly converting an int value to a bool, the compiler makes some assumptions based on the types and values being passed in, along with (possibly) a single jump condition. It is also possible that the compiler completely optimizes away the jmps with bit shifts.

提交回复
热议问题