binutils Newspaper
OCTOBER 6, 2026
x86 — Under Review — Sentiment 5 / 10

x86: Support BHI_CTRL instruction

Discussion continues on the x86 BHI_CTRL instruction support, specifically regarding the correct handling of REX.W and REX2.W prefixes.

This discussion revolves around the correct implementation of the BHI_CTRL instruction for x86 in binutils, particularly concerning the encoding and usage of REX prefixes. The initial patch proposed using Size64 to ensure REX.W is emitted. A key point of debate is whether REX2.W should have the same effect as REX.W for this instruction, as the documentation is unclear. There’s a call for a test case to clarify this behavior and ensure the disassembler handles potential ambiguities correctly.

In the Thread 4 participants
  1. Jan Beulich reviewer

    Questions whether REX2.W would have the same effect as REX.W for the BHI_CTRL instruction and suggests a test case.

    “So Size64 is here to have REX.W emitted. The whitepaper isn't clear about APX at all, though: Would REX2.W also have the same effect? (Whichever way it is, this then perhaps also wants covering in the testsuite.)”
  2. Jiang, Haochen proposer

    Clarifies that the encoding is fixed and REX2.W won't have the same effect, but welcomes a test case.

    “No, it won't. The encoding is fixed. But a testcase is welcomed here to clarify.”
  3. Jan Beulich reviewer

    Expresses concern that the disassembler might not reject REX2.W and questions the differing behavior of W bits in REX vs. REX2.

    “But you had a good point here, the current disassembler won't "reject" rex2.w (i.e., not taking this back to nop from my understanding) and take it as rex.w. This let me further wonder if a user input something like "{rex2} ibhf", should we accept that?”
  4. Jiang, Haochen proposer

    States that REX2.W should be accepted if it results in the intended encoding, but notes that REX2.W does not have the same effect as REX.W.

    “We should accept it if the resulting encoding does what is intended / written. According to Christian's reply REX2.W doesn't have the same effect, but I wonder if it's really sensible that way.”

In Details

The discussion concerns the x86 instruction BHI_CTRL and its encoding within binutils. Specifically, it delves into the interaction between the instruction's encoding and the REX prefix, particularly REX.W vs. REX2.W. The Size64 flag in the opcode table is used to ensure REX.W is emitted, but there's ambiguity about REX2.W's behavior and whether the disassembler should accept constructions like {rex2} ibhf. This touches on the precise semantics of REX prefixes in modern x86 extensions.

For Context
BHI_CTRL
An x86 instruction related to Branch History Buffer control.
REX prefix
An instruction prefix in x86 architecture used to extend the instruction set, including enabling 64-bit operands (REX.W).
REX.W
The W bit in the REX prefix, which signifies a 64-bit operand size.
REX2.W
An alternative REX prefix encoding that also controls operand size.
disassembler
A tool that translates machine code back into human-readable assembly language.
opcode table
A data structure used by assemblers and disassemblers to map instruction mnemonics and operands to their corresponding machine code.
APX
Likely refers to AMD's Advanced Performance Extensions or a similar microarchitecture extension.
Filed Under: x86disassemblerinstruction-encoding