[llvm] [RISCV] Lower f16/bf16 splat_vector by bitcasting to i16 instead of promoting to f16. (PR #108298)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 11 18:12:10 PDT 2024


================
@@ -3,22 +3,58 @@
 ; RUN:   | FileCheck %s
 ; RUN: llc -mtriple=riscv64 -mattr=+f,+d,+zfbfmin,+zvfbfmin,+v -target-abi lp64d -verify-machineinstrs < %s \
 ; RUN:   | FileCheck %s
+; RUN: llc -mtriple=riscv32 -mattr=+f,+d,+zvfbfmin,+v -target-abi ilp32d -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s --check-prefixes=NOZFBFMIN
+; RUN: llc -mtriple=riscv64 -mattr=+f,+d,+zvfbfmin,+v -target-abi lp64d -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s --check-prefixes=NOZFBFMIN
 
-define <vscale x 8 x bfloat> @vsplat_zero_nxv8f16() {
-; CHECK-LABEL: vsplat_zero_nxv8f16:
+define <vscale x 8 x bfloat> @vsplat_nxv8bf16(bfloat %f) {
+; CHECK-LABEL: vsplat_nxv8bf16:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    fmv.x.h a0, fa0
+; CHECK-NEXT:    vsetvli a1, zero, e16, m2, ta, ma
+; CHECK-NEXT:    vmv.v.x v8, a0
+; CHECK-NEXT:    ret
+;
+; NOZFBFMIN-LABEL: vsplat_nxv8bf16:
+; NOZFBFMIN:       # %bb.0:
+; NOZFBFMIN-NEXT:    fmv.x.w a0, fa0
+; NOZFBFMIN-NEXT:    vsetvli a1, zero, e16, m2, ta, ma
+; NOZFBFMIN-NEXT:    vmv.v.x v8, a0
----------------
lukel97 wrote:

Ah I see how we can truncate the bits for bf16.

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


More information about the llvm-commits mailing list