llvm / llvm/llvm-project

[AVX10.2] Move out mask from bias convert (VCVTBIAS)* instruction intrinsic arguments

Open
#180,695 2 comments 0 reactions 0 assignees View on GitHub
backend:X86
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

In 1 of motivating case, we compute bias twice since mask combine did went through.

```c
__m128i foo(__m128i __W, __mmask8 __U, __m128i __A, __m128h __B) {
return _mm_mask_cvtbiasph_bf8(__W, 0xf0, __A, __B) + _mm_mask_cvtbiasph_bf8(__W, 0x0f, __A, __B);
}

__m128i bar(__m128i __W, __mmask8 __U, __m128i __A, __m128h __B) {
return _mm_mask_dpph_ps(__W, 0xf0, __A, __B) + _mm_mask_dpph_ps(__W, 0x0f, __A, __B);
}
```

```asm
foo(long long vector[2], unsigned char, long long vector[2], _Float16 vector[8]):
mov al, -16
kmovd k1, eax
vmovaps xmm3, xmm0
vcvtbiasph2bf8 xmm3 {k1}, xmm1, xmm2
mov al, 15
kmovd k1, eax
vcvtbiasph2bf8 xmm0 {k1}, xmm1, xmm2
vpaddq xmm0, xmm0, xmm3
ret

bar(long long vector[2], unsigned char, long long vector[2], _Float16 vector[8]):
vmovaps xmm3, xmm0
vdpphps xmm3, xmm1, xmm2
vaddps xmm0, xmm3, xmm0
ret
```
Notice vcvtbiasph2bf8 did not combine mask, whereas vdphps successfully combined 0xf0 and 0x0f into 0xff -> no-mask version.
We may need to use __builtin_select in bias intrinsic functions to let transform succeed.

Ref : https://godbolt.org/z/s51W33Ph1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.