Instruction
Jcc
Jumps to a relative target if a condition on the flags holds, such as JZ when ZF is set or JL when SF differs from OF.
- Extensions
- Mnemonics
- JO, JNO, JB, JC, JNAE, JNB, JNC, JAE, JZ, JE, JNZ, JNE, JBE, JNA, JNBE, JA, JS, JNS, JP, JPE, JNP, JPO, JL, JNGE, JNL, JGE, JLE, JNG, JNLE, JG
- Forms
- 3 (3 Legacy)
- Data
- Intel XED v2026.08.23
A conditional jump almost always follows a CMP or TEST, and which mnemonic to use depends on whether the values compared are signed. After CMP a, b:
| Relation | Unsigned | Signed |
|---|---|---|
a == b | JE (JZ) | JE (JZ) |
a != b | JNE (JNZ) | JNE (JNZ) |
a < b | JB (JC, JNAE) | JL (JNGE) |
a <= b | JBE (JNA) | JLE (JNG) |
a > b | JA (JNBE) | JG (JNLE) |
a >= b | JAE (JNB, JNC) | JGE (JNL) |
“Below” and “above” are the unsigned words, “less” and “greater” the signed ones. After TEST x, x, JZ means x is zero and JS that it is negative. The same four-bit condition code, whose lowest bit inverts the test, selects the condition in SETcc, CMOVcc and APX’s CCMPscc and CFCMOVcc.
Each condition has two encodings: 70+cc with an 8-bit displacement (2 bytes, for targets up to 128 bytes away) and 0F 80+cc with a 32-bit one (6 bytes). As for JMP and CALL, Intel’s manual fixes the operand size of near branches at 64 bits in 64-bit mode. AMD’s lets a 66 prefix make a Jcc 16 bits: a 2-byte displacement in the 0F 80+cc form and RIP cut to 16 bits, so those bytes have different lengths on the two.
Performance, by the vendors’ optimization manuals:
- Fusion. A CMP or TEST (and some arithmetic) directly followed by a Jcc is decoded as one operation. On Intel’s cores since Haswell, TEST and AND fuse with every condition, and CMP, ADD and SUB with all but the overflow, sign and parity ones, never when the first instruction has both a memory operand and an immediate. On Zen 5, CMP, TEST, SUB, ADD, INC, DEC, OR, AND and XOR fuse.
- Hints. The 3E prefix is a “taken” hint. From Intel’s Redwood Cove cores on, the processor uses it for a branch it has no history of; the 2E “not taken” hint is ignored.
- Unpredictable branches. Intel’s optimization manual suggests CMOVcc or SETcc in their place, but not for branches that predict well.
JRCXZ and LOOP are the jumps that test RCX rather than the flags.
In the optimization guide
What the optimization guide says about Jcc, a line per claim. Each links to the claim in the guide, with its sources and where they differ.
Front end
- Macro-fusion: Macro-fusion turns an instruction that sets the flags and the conditional branch right after it into one operation, which takes one slot in decode, rename and retirement.
- Macro-fusion: Intel’s cores since Sandy Bridge (Skylake) fuse
testandandwith any conditional branch;cmp,addandsubwith branches on the equal, unsigned and signed comparisons, but not on the sign, parity or overflow flag alone; andincanddeconly with branches on equality and the signed comparisons. - Macro-fusion: AMD’s Zen 3 to Zen 5 fuse more:
cmp,test,add,sub,and,or,xor,incanddecwith any conditional branch, except that on Zen 3 and Zen 4incanddecdo not fuse with a branch that reads the carry flag, which Intel’s cores do not fuse either (Zen 5, Zen 4, Zen 3). sources differ - Code alignment and padding: On the Skylake family with the microcode update for its JCC erratum (Skylake), 32-byte boundaries matter for every jump: one that crosses such a boundary or ends on it is no longer cached and runs from the decoders.
Branches
- Direction and target: A conditional branch the predictor knows nothing about is predicted not taken. sources differ
- Direction and target: Prefixes 2Eh and 3Eh before a conditional jump once served as static hints, on the Pentium 4.
- Direction and target: LLVM 23.1.2 emits the taken hint only for Granite Rapids (
-mtune=graniterapids), only with the hidden option-enable-branch-hint, and only on jumps that its branch probabilities put above 50%.
Bulldozer to Excavator
- Branches: A
cmportestdirectly followed by a conditional branch fuses into one op, unless the compare uses a RIP-relative address or has a displacement as well as an immediate; no other instruction fuses. sources differ
Golden Cove and Raptor Cove
- Branches: A conditional branch the predictor holds no history for is predicted not taken, so the rarely run branches that are usually taken cost a misprediction.
Ice Lake to Rocket Lake
- Front end: A
cmp,add,sub,incordecfuses with a following jump on zero, carry or an unsigned or signed comparison, andtestorandwith any conditional jump;or,xor,adc,sbb, shifts andjs,joandjpnever fuse.
Redwood Cove
- Branches: A conditional jump with a 3Eh prefix is a taken hint: when the predictor holds nothing on the branch, the decoder turns its default not-taken guess into taken and fetches from the target.
- Branches: The hint applies to Jcc only, not to
jrcxzorloop. - Branches: Hints pay on branches that run rarely and are mostly taken, where the predictor has likely forgotten them, as in programs with more branches than the predictor holds; on a hot branch it only makes the code longer.
- Branches: Redwood Cove’s performance events find the branches that a taken hint would help.
Silvermont to Goldmont Plus
- Front end: Back-to-back branches cost Silvermont and Goldmont 3 cycles in the decoders.
Skylake to Cooper Lake
- Front end:
testandandfuse with any following conditional jump;cmp,addandsubwith the jumps on equality and on the unsigned and signed comparisons, but not withjs,jporjoand their inverses;incanddeconly with those on equality and the signed comparisons. - The JCC erratum: Under rare conditions a jump that crosses a 64-byte line could make these cores misbehave (erratum SKX102).
Zen and Zen+
- Integer execution: Only a
cmportestdirectly followed by a conditional branch fuses into one macro-op, and not when it has a displacement together with an immediate, or an address relative to RIP; no other arithmetic or logic instruction fuses.
Zen 2
- Integer execution: Only a
cmportestfollowed by a conditional branch fuses into one macro-op, not one with a displacement together with an immediate or an address relative to RIP; the arithmetic and logic instructions that fuse on Zen 3 do not.
Zen 3
- Integer execution: A
cmp,test,add,sub,inc,dec,and,ororxorfollowed by a conditional branch becomes one macro-op, also with a memory operand, unless it carries a displacement together with an immediate, addresses relative to RIP or makes the pair longer than 15 bytes;incanddecdo not fuse with a branch on the carry flag, andjrcxznever fuses.
Zen 4
- Integer execution: A
cmp,test,add,sub,inc,dec,and,ororxorfollowed by a conditional branch becomes one macro-op, also with a memory operand, unless it carries a displacement together with an immediate, addresses relative to RIP or makes the pair longer than 15 bytes;incanddecdo not fuse with a branch on the carry flag.
Zen 5
- Integer execution: A
cmp,test,add,sub,inc,dec,and,ororxorfollowed by a conditional branch becomes one macro-op, also with a memory operand, within limits on the sizes of its displacement and immediate.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
Jcc rel8
Jcc_RELBRb | 70+cc cb | Base instruction set |
Jcc rel32 64-bit mode only
Jcc_RELBRd | 0F 80+cc cd | Base instruction set |
Jcc rel16/32 not in 64-bit mode
Jcc_RELBRz | 0F 80+cc cw/cd | Base instruction set |
Latency and throughput
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
w = OSIZE # the size of the target
n = 0
if OSIZE == 16: # a 66 prefix
if INTEL:
w = 64 # ignored: SDM
else:
if rel.bits == 32:
n = 2 # a rel16, 2 bytes shorter than XED
# decodes: APM, Zen 5
if cond(CC): # the flags from before the instruction
t = low(rip - n + signed(rel), w)
if not canonical(t):
fault(GP, 0)
rip = t
else:
rip = rip - n # on to the next instruction
Run on AMD Zen 5 (EPYC 9645): 101 cases. Its branches for Intel's processors were not run: no Intel processor ran these forms. The forms that 64-bit mode lacks were not run: the probe runs in 64-bit mode.
Operands
| Operand | Kind | Action |
|---|---|---|
Jcc rel8 Jcc rel32 64-bit mode only Jcc rel16/32 not in 64-bit mode | ||
rel8/16/32 | explicit | read |
rIP | implicit | read, write |
RFLAGS | implicit | read |
Flags
| When | OF | SF | ZF | PF | CF |
|---|---|---|---|---|---|
| All forms | |||||
| JO | T | ||||
| JNO | T | ||||
| JB | T | ||||
| JNB | T | ||||
| JZ | T | ||||
| JNZ | T | ||||
| JBE | T | T | |||
| JNBE | T | T | |||
| JS | T | ||||
| JNS | T | ||||
| JP | T | ||||
| JNP | T | ||||
| JL | T | T | |||
| JNL | T | T | |||
| JLE | T | T | T | ||
| JNLE | T | T | T | ||
CPUID and processors
Each form belongs to an XED ISA set. A form can be used when the processor reports every CPUID bit of one of its ISA set's alternatives.
| ISA set | CPUID | Processors |
|---|---|---|
I86 | No CPUID bit: part of the base instruction set. | Every x86-64 processor in XED’s model and Zen 3 to Zen 6 |
More General-purpose instructions
Sources
- Intel XED v2026.08.23 (commit
0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model. - The CPU data of x86-64.net: Zen 3 to Zen 6, from GCC’s
-marchfeature sets and AMD’s Processor Programming References, which the page of each processor cites. - LLVM 23.1.2's x86 scheduling models (commit
85ac56026243): the latency, reciprocal throughput and ports of each form, as llvm-mca reports them. - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2A, page 3-499 (Jcc)
- Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1 (253665-093, September 2026)
- AMD64 Architecture Programmer's Manual, Volume 2: System Programming (24593, rev. 3.46, October 2026)
- AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and System Instructions (24594, rev. 3.39, October 2026)
- Intel 64 and IA-32 Architectures Optimization Reference Manual, Volume 1 (248966-051, October 2026)
- Software Optimization Guide for the AMD Zen5 Microarchitecture (58455, rev. 1.00, August 2024), Wayback Machine copy of AMD's ZIP
The tables are derived from Intel XED, Copyright Intel Corporation, licensed under the Apache License 2.0; x86-64.net converted and reformatted them. The timings come from LLVM's scheduling models, part of the LLVM Project, licensed under the Apache License 2.0 with LLVM Exceptions. The text is our own.