[llvm] [X86][X86CompressEVEX] Do not compress when there is a compressed disp8 (PR #221923)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 8 02:51:52 PDT 2026
nishant-sachdeva-amd wrote:
Can we find a way to share the check with the code already present in `X86BaseInfo.h` ?
```
/// True when an EVEX memory operand with raw byte displacement \p D and CDisp8
/// access size \p N encodes strictly smaller than the non-EVEX (VEX/legacy) form
/// would: EVEX spends a 1-byte scaled disp8 where the other form is forced to a
/// 4-byte disp32. This is the size-peer of X86MCCodeEmitter::isDispOrCDisp8 and
/// must stay in lockstep with it:
/// 1. D outside [-128,127] -- else the non-EVEX form already uses a 1-byte
/// disp8 (which spans -128..127), so the wider EVEX
/// prefix would only grow the encoding.
/// 2. D % N == 0 -- CDisp8 can only represent exact multiples of N.
/// 3. isInt<8>(D / N) -- the compressed displacement is a signed byte.
/// Direction-agnostic: used both by the VEX->EVEX promote pass and the
/// EVEX->VEX demotion veto in CompressEVEX.
inline bool cdisp8BeatsDisp32(int64_t D, int64_t N) {
if (D >= -128 && D <= 127)
return false;
if (D % N != 0)
return false;
int64_t Scaled = D / N;
return Scaled >= -128 && Scaled <= 127;
}
```
https://github.com/llvm/llvm-project/pull/221923
More information about the llvm-commits
mailing list