[llvm] [X86][APX] Avoid generating illegal MI_ND ndd instructions (PR #78233)

Shengchen Kan via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 17 01:01:01 PST 2024


KanRobert wrote:

> The instruction-size limit of 15 bytes still applies to APX instructions.
> 
> Note that it is possible for an EVEX-encoded legacy instruction to reach the 15-byte instruction length limit: 4 bytes of EVEX prefix + 1 byte of opcode + 1 byte of ModRM + 1 byte of SIB + 4 bytes of displacement + 4 bytes of immediate = 15 bytes in total, e.g.
> 
> ```
> addq    $184, -96, %rax   # encoding: [0x62,0xf4,0xfc,0x18,0x81,0x04,0x25,0xa0,0xff,0xff,0xff,0xb8,0x00,0x00,0x00]
> ```
> 
> If we added a segment prefix like fs, the length would be 16.
> 
> In such a case, no additional (ASIZE or segment override) prefix can be used. Since this limit is reached only when there is a long immediate, compiler can first load the immediate into a register and then apply the desired prefix(es) to the shorter register-source version of the same instruction class.

@XinWang10 Updated the description for you. In the expand-pseudo solution (discussed offline), you also need to consider the address size prefix.

https://github.com/llvm/llvm-project/pull/78233


More information about the llvm-commits mailing list