简体   繁体   中英

assembly - x86_64 - predicates

I am coding some assembly for x86_64 and arm.

I would like to know whether x86_64 has some ways to define branch predicates.

I searched in Intel documentation but failed to find relevant info.

We have cmov but it is rather slow and a cmp jmp combo tends to be faster.

ARM predicates are an alternative to branches. IDK what you mean by "branch predicates". Maybe you mean "predicate conditions"?

cmov is often worth it compared to a branch that only skips over one or two instructions, if it's at all unpredictable. Broadwell and Skylake run cmov as a single uop, but previous microarchitectures need 2 uops since it has 3 input dependencies. It also creates a data dependency instead of a control dependency. Branch prediction, when it works, can be better. Also, cmov can't take an immediate operand, which is frustrating in many cases.

Another instruction that can use a condition as an input is setcc . Use xor reg,reg / set flags / setcc low-byte-of-reg , to avoid partial-reg stalls when reading the full register.

For the carry condition, sbb same,same will produce 0 or -1 (useful as an AND mask), or adc reg, 0 will do reg += CF .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM