3 ms·
> So you have to follow a comparison operation with either a conditional branch or a conditional move (and earlier processors in the x86 family didn't have cond
by xoranth 3y ago
> So you have to follow a comparison operation with either a conditional branch or a conditional move (and earlier processors in the x86 family didn't have conditional moves).
The x86 family has the `setCC` instructions [^1] that move bits from the flag register to a general purpose one. Example from godbolt, see `setg`:
https://c.godbolt.org/z/MY37oP9vz https://c.godbolt.org/z/MY37oP9vz
[^1]: https://www.felixcloutier.com/x86/setcc https://www.felixcloutier.com/x86/setcc
- gpderetta 3y agoSETcc is indeed what GCC typically uses. You can also play tricks with the carry flag and ADC but I don't think I have ever seen GCC do it.
- xoranth 3y agoThe latest version can [^1], though anecdotally I've seen clang/LLVM being smarter about it. [^1]: https://c.godbolt.org/z/vP8edfen7 https://c.godbolt.org/z/vP8edfen7