我正在读一本书,作者说这if( a < 901 )比书更快if( a <= 900 ).
if( a < 901 )
if( a <= 900 )
与此简单示例不完全相同,但循环复杂代码略有性能变化.我想这必须对生成的机器代码做一些事情,以防它甚至是真的.
c++ performance assembly relational-operators
我认为因为条件是> = 3,我们应该使用jl(更少).
jl
但gcc使用jle(少或相等).
jle
这对我没有意义; 为什么编译器会这样做?
c x86 assembly gcc
assembly ×2
c ×1
c++ ×1
gcc ×1
performance ×1
relational-operators ×1
x86 ×1