为什么相等的c ++代码转换为不同的asm代码?

WOR*_*SER -3 c++ optimization performance assembly visual-c++

Visual c ++,调试模式.

if(k>=0)

011D14CE  cmp         dword ptr [k],0  
011D14D2  jl          bez+28h (11D14D8h)  

return true;

011D14D4  mov         al,1  
011D14D6  jmp         bez+33h (11D14E3h)  

return false;
011D14D8  xor         al,al  
011D14DA  jmp         bez+33h (11D14E3h)  
Run Code Online (Sandbox Code Playgroud)

和平等的代码:

return (k>=0)?(true):(false);
011D14DC  cmp         dword ptr [k],0  
011D14E0  setge       al  
Run Code Online (Sandbox Code Playgroud)

什么更快?当我在函数调用中使用第二个构造时,什么更快?

if(i>0)
    Foo(true);
else
    Foo(false);
Run Code Online (Sandbox Code Playgroud)

要么:

Foo((i>0)?(true):(false))
Run Code Online (Sandbox Code Playgroud)

650*_*502 10

在调试模式下编译时,该代码不相等.在第一个版本中,您可以在return true分支上设置断点.这不能用setge al.