| Issue |
233852
|
| Summary |
[X86][AsmParser] AVX512PF Intel syntax rejects memory operands with mask decorators
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
simhyeongseop
|
### Summary
With llvm-mc 23.1.3, AVX512PF gather/scatter prefetch instructions assemble in AT&T syntax but fail in Intel syntax. LLVM also emits Intel disassembly that its own assembler rejects.
### Reproducer
Intel syntax:
```sh
printf ".intel_syntax noprefix\nvgatherpf0dps [rax+zmm0] {k1}\n" | llvm-mc -triple=x86_64 -show-encoding
```
Result: `error: invalid operand for instruction`. The correctly sized form `vgatherpf0dps dword ptr [rax+zmm0] {k1}` is also rejected.
Equivalent AT&T syntax succeeds:
```sh
echo 'vgatherpf0dps (%rax,%zmm0) {%k1}' | llvm-mc -triple=x86_64 -show-encoding
```
Encoding: `[0x62,0xf2,0x7d,0x49,0xc6,0x0c,0x00]`.
### Intel disassembly does not round-trip
```sh
echo "0x62,0xf2,0x7d,0x49,0xc6,0x0c,0x00" | llvm-mc -triple=x86_64 --disassemble --output-asm-variant=1
```
Output:
```asm
vgatherpf0dps {k1}, dword ptr [rax + zmm0]
```
Reassembling this output:
```sh
printf ".intel_syntax noprefix\nvgatherpf0dps {k1}, dword ptr [rax + zmm0]\n" | llvm-mc -triple=x86_64 -show-encoding
```
Result: `error: unknown token in _expression_`.
### Expected behavior
Accept the memory operand followed by the mask decorator, and emit Intel syntax that can be assembled again.
Intel SDM revision 093, Vol. 2D, page 8-12 lists `VGATHERPF0DPS vm32z {k1}`. Vol. 1, section 15.6.1.2, page 15-10 also describes predicate opmasks as decorators following the first operand in Intel syntax.
For comparison, GNU as (GNU Binutils 2.47.20260726) accepts `vgatherpf0dps dword ptr [rax+zmm0] {k1}` and emits the same bytes.
### Scope
All 16 AVX512PF gather/scatter prefetch instructions were checked: AT&T forms assemble, Intel forms (both unsized and appropriately sized memory operands) are rejected, and LLVM Intel output fails to reassemble. The four DPD forms use a YMM index; the other twelve use a ZMM index. This was an assembly/disassembly check, not CPU execution.
### Related discussion and likely cause
The mask position was previously discussed in PR #122051, including a concrete format-change suggestion:
https://github.com/llvm/llvm-project/pull/122051#issuecomment-2576984459
In the tested version, `avx512_gather_scatter_prefetch` still defines the Intel variant with the mask as a separate leading operand, while the AT&T variant places it after memory:
https://github.com/llvm/llvm-project/blob/0d261d1ca552c95a8f007e061c787ac7132fbcbc/llvm/lib/Target/X86/X86InstrAVX512.td#L10434-L10440
The leading `{k1}` is rejected by the Intel parser; the trailing memory mask form does not match this instruction definition. A possible fix is to put the mask after the memory operand in the Intel format and add Intel assembly/disassembly round-trip tests. A patched LLVM build has not been tested.
### Environment and Compiler Explorer
- Local: llvm-mc 23.1.3, Linux x86-64.
- Compiler Explorer examples use Clang 23.1.0:
- Intel syntax rejected: https://godbolt.org/z/of1hfozfa
- AT&T syntax accepted: https://godbolt.org/z/Goo8f9jvd
- The latest LLVM main build has not been tested.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs