[llvm] [X86] Add support for `__bf16` to `f16` conversion (PR #134859)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 8 07:19:56 PDT 2025


================
@@ -2456,6 +2456,11 @@ let Predicates = [HasFP16] in {
             (VCMPSHZrmi FR16X:$src1, addr:$src2, (X86cmpm_imm_commute timm:$cc))>;
 }
 
+let Predicates = [HasAVX512, HasBF16] in {
+  def : Pat<(f16 (bitconvert (bf16 FR16X:$src))), (f16 FR16X:$src)>;
+  def : Pat<(bf16 (bitconvert (f16 FR16X:$src))), (bf16 FR16X:$src)>;
+}
----------------
antoniofrighetto wrote:

@phoebewang Could we reuse `FR16X` for bf16 as well here? Changing FR16X definition to include bf16:


```
def FR16X : RegisterClass<"X86", [f16, bf16], 16, (add FR32X)> {let Size = 32;}
```
Seems to lead to a bunch of compilation issues due to ambiguity in instruction pattern :( Should we create a new class?

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


More information about the llvm-commits mailing list