-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RISCV] Lower scalar_to_vector for supported FP types (#114340)
In https://reviews.llvm.org/D147608 we added custom lowering for integers, but inadvertently also marked it as custom for scalable FP vectors despite not handling it. This adds handling for floats and marks it as custom lowered for fixed-length FP vectors too. Note that this doesn't handle bf16 or f16 vectors that would need promotion, but these scalar_to_vector nodes seem to be emitted when expanding them.
- Loading branch information
Showing
4 changed files
with
146 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc < %s -mtriple=riscv32 -mattr=+v -verify-machineinstrs | FileCheck %s | ||
; RUN: llc < %s -mtriple=riscv64 -mattr=+v -verify-machineinstrs | FileCheck %s | ||
|
||
define <8 x float> @fpext_v8bf16(<8 x bfloat> %x) { | ||
; CHECK-LABEL: fpext_v8bf16: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: fmv.x.w a0, fa0 | ||
; CHECK-NEXT: fmv.x.w a1, fa1 | ||
; CHECK-NEXT: fmv.x.w a2, fa2 | ||
; CHECK-NEXT: fmv.x.w a3, fa3 | ||
; CHECK-NEXT: fmv.x.w a4, fa4 | ||
; CHECK-NEXT: fmv.x.w a5, fa5 | ||
; CHECK-NEXT: fmv.x.w a6, fa6 | ||
; CHECK-NEXT: fmv.x.w a7, fa7 | ||
; CHECK-NEXT: slli a7, a7, 16 | ||
; CHECK-NEXT: vsetivli zero, 2, e32, mf2, ta, ma | ||
; CHECK-NEXT: vmv.s.x v8, a7 | ||
; CHECK-NEXT: slli a6, a6, 16 | ||
; CHECK-NEXT: vmv.s.x v9, a6 | ||
; CHECK-NEXT: vslideup.vi v9, v8, 1 | ||
; CHECK-NEXT: slli a5, a5, 16 | ||
; CHECK-NEXT: vmv.s.x v8, a5 | ||
; CHECK-NEXT: slli a4, a4, 16 | ||
; CHECK-NEXT: vmv.s.x v10, a4 | ||
; CHECK-NEXT: vslideup.vi v10, v8, 1 | ||
; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma | ||
; CHECK-NEXT: vslideup.vi v10, v9, 2 | ||
; CHECK-NEXT: slli a3, a3, 16 | ||
; CHECK-NEXT: vmv.s.x v8, a3 | ||
; CHECK-NEXT: slli a2, a2, 16 | ||
; CHECK-NEXT: vmv.s.x v9, a2 | ||
; CHECK-NEXT: vsetivli zero, 2, e32, mf2, ta, ma | ||
; CHECK-NEXT: vslideup.vi v9, v8, 1 | ||
; CHECK-NEXT: slli a1, a1, 16 | ||
; CHECK-NEXT: vmv.s.x v11, a1 | ||
; CHECK-NEXT: slli a0, a0, 16 | ||
; CHECK-NEXT: vmv.s.x v8, a0 | ||
; CHECK-NEXT: vslideup.vi v8, v11, 1 | ||
; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma | ||
; CHECK-NEXT: vslideup.vi v8, v9, 2 | ||
; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma | ||
; CHECK-NEXT: vslideup.vi v8, v10, 4 | ||
; CHECK-NEXT: ret | ||
%y = fpext <8 x bfloat> %x to <8 x float> | ||
ret <8 x float> %y | ||
} | ||
|
||
define <8 x float> @fpext_v8f16(<8 x bfloat> %x) { | ||
; CHECK-LABEL: fpext_v8f16: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: fmv.x.w a0, fa0 | ||
; CHECK-NEXT: fmv.x.w a1, fa1 | ||
; CHECK-NEXT: fmv.x.w a2, fa2 | ||
; CHECK-NEXT: fmv.x.w a3, fa3 | ||
; CHECK-NEXT: fmv.x.w a4, fa4 | ||
; CHECK-NEXT: fmv.x.w a5, fa5 | ||
; CHECK-NEXT: fmv.x.w a6, fa6 | ||
; CHECK-NEXT: fmv.x.w a7, fa7 | ||
; CHECK-NEXT: slli a7, a7, 16 | ||
; CHECK-NEXT: vsetivli zero, 2, e32, mf2, ta, ma | ||
; CHECK-NEXT: vmv.s.x v8, a7 | ||
; CHECK-NEXT: slli a6, a6, 16 | ||
; CHECK-NEXT: vmv.s.x v9, a6 | ||
; CHECK-NEXT: vslideup.vi v9, v8, 1 | ||
; CHECK-NEXT: slli a5, a5, 16 | ||
; CHECK-NEXT: vmv.s.x v8, a5 | ||
; CHECK-NEXT: slli a4, a4, 16 | ||
; CHECK-NEXT: vmv.s.x v10, a4 | ||
; CHECK-NEXT: vslideup.vi v10, v8, 1 | ||
; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma | ||
; CHECK-NEXT: vslideup.vi v10, v9, 2 | ||
; CHECK-NEXT: slli a3, a3, 16 | ||
; CHECK-NEXT: vmv.s.x v8, a3 | ||
; CHECK-NEXT: slli a2, a2, 16 | ||
; CHECK-NEXT: vmv.s.x v9, a2 | ||
; CHECK-NEXT: vsetivli zero, 2, e32, mf2, ta, ma | ||
; CHECK-NEXT: vslideup.vi v9, v8, 1 | ||
; CHECK-NEXT: slli a1, a1, 16 | ||
; CHECK-NEXT: vmv.s.x v11, a1 | ||
; CHECK-NEXT: slli a0, a0, 16 | ||
; CHECK-NEXT: vmv.s.x v8, a0 | ||
; CHECK-NEXT: vslideup.vi v8, v11, 1 | ||
; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma | ||
; CHECK-NEXT: vslideup.vi v8, v9, 2 | ||
; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma | ||
; CHECK-NEXT: vslideup.vi v8, v10, 4 | ||
; CHECK-NEXT: ret | ||
%y = fpext <8 x bfloat> %x to <8 x float> | ||
ret <8 x float> %y | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters