Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RISCV] Add rvv codegen support for vp.fpext.
This patch adds rvv codegen support for vp.fpext. The lowering of fp_round, vp.fptrunc, fp_extend and vp.fpext share most code so use a common lowering function to handle these four. And this patch changes the intermediate cast from ISD::FP_EXTEND/ISD::FP_ROUND to the RVV VL version op RISCVISD::FP_EXTEND_VL and RISCVISD::FP_ROUND_VL for scalable vectors. Reviewed By: frasercrmck Differential Revision: https://reviews.llvm.org/D123975
- Loading branch information
jacquesguan
authored and
jacquesguan
committed
May 11, 2022
1 parent
d4609ae
commit 2509dcd
Showing
4 changed files
with
190 additions
and
75 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
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,77 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc -mtriple=riscv32 -mattr=+d,+zfh,+experimental-zvfh,+v -riscv-v-vector-bits-min=128 -verify-machineinstrs < %s | FileCheck %s | ||
; RUN: llc -mtriple=riscv64 -mattr=+d,+zfh,+experimental-zvfh,+v -riscv-v-vector-bits-min=128 -verify-machineinstrs < %s | FileCheck %s | ||
|
||
declare <2 x float> @llvm.vp.fpext.v2f32.v2f16(<2 x half>, <2 x i1>, i32) | ||
|
||
define <2 x float> @vfpext_v2f16_v2f32(<2 x half> %a, <2 x i1> %m, i32 zeroext %vl) { | ||
; CHECK-LABEL: vfpext_v2f16_v2f32: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: vsetvli zero, a0, e16, mf4, ta, mu | ||
; CHECK-NEXT: vfwcvt.f.f.v v9, v8, v0.t | ||
; CHECK-NEXT: vmv1r.v v8, v9 | ||
; CHECK-NEXT: ret | ||
%v = call <2 x float> @llvm.vp.fpext.v2f32.v2f16(<2 x half> %a, <2 x i1> %m, i32 %vl) | ||
ret <2 x float> %v | ||
} | ||
|
||
define <2 x float> @vfpext_v2f16_v2f32_unmasked(<2 x half> %a, i32 zeroext %vl) { | ||
; CHECK-LABEL: vfpext_v2f16_v2f32_unmasked: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: vsetvli zero, a0, e16, mf4, ta, mu | ||
; CHECK-NEXT: vfwcvt.f.f.v v9, v8 | ||
; CHECK-NEXT: vmv1r.v v8, v9 | ||
; CHECK-NEXT: ret | ||
%v = call <2 x float> @llvm.vp.fpext.v2f32.v2f16(<2 x half> %a, <2 x i1> shufflevector (<2 x i1> insertelement (<2 x i1> undef, i1 true, i32 0), <2 x i1> undef, <2 x i32> zeroinitializer), i32 %vl) | ||
ret <2 x float> %v | ||
} | ||
|
||
declare <2 x double> @llvm.vp.fpext.v2f64.v2f16(<2 x half>, <2 x i1>, i32) | ||
|
||
define <2 x double> @vfpext_v2f16_v2f64(<2 x half> %a, <2 x i1> %m, i32 zeroext %vl) { | ||
; CHECK-LABEL: vfpext_v2f16_v2f64: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: vsetvli zero, a0, e16, mf4, ta, mu | ||
; CHECK-NEXT: vfwcvt.f.f.v v9, v8, v0.t | ||
; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, mu | ||
; CHECK-NEXT: vfwcvt.f.f.v v8, v9, v0.t | ||
; CHECK-NEXT: ret | ||
%v = call <2 x double> @llvm.vp.fpext.v2f64.v2f16(<2 x half> %a, <2 x i1> %m, i32 %vl) | ||
ret <2 x double> %v | ||
} | ||
|
||
define <2 x double> @vfpext_v2f16_v2f64_unmasked(<2 x half> %a, i32 zeroext %vl) { | ||
; CHECK-LABEL: vfpext_v2f16_v2f64_unmasked: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: vsetvli zero, a0, e16, mf4, ta, mu | ||
; CHECK-NEXT: vfwcvt.f.f.v v9, v8 | ||
; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, mu | ||
; CHECK-NEXT: vfwcvt.f.f.v v8, v9 | ||
; CHECK-NEXT: ret | ||
%v = call <2 x double> @llvm.vp.fpext.v2f64.v2f16(<2 x half> %a, <2 x i1> shufflevector (<2 x i1> insertelement (<2 x i1> undef, i1 true, i32 0), <2 x i1> undef, <2 x i32> zeroinitializer), i32 %vl) | ||
ret <2 x double> %v | ||
} | ||
|
||
declare <2 x double> @llvm.vp.fpext.v2f64.v2f32(<2 x float>, <2 x i1>, i32) | ||
|
||
define <2 x double> @vfpext_v2f32_v2f64(<2 x float> %a, <2 x i1> %m, i32 zeroext %vl) { | ||
; CHECK-LABEL: vfpext_v2f32_v2f64: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, mu | ||
; CHECK-NEXT: vfwcvt.f.f.v v9, v8, v0.t | ||
; CHECK-NEXT: vmv1r.v v8, v9 | ||
; CHECK-NEXT: ret | ||
%v = call <2 x double> @llvm.vp.fpext.v2f64.v2f32(<2 x float> %a, <2 x i1> %m, i32 %vl) | ||
ret <2 x double> %v | ||
} | ||
|
||
define <2 x double> @vfpext_v2f32_v2f64_unmasked(<2 x float> %a, i32 zeroext %vl) { | ||
; CHECK-LABEL: vfpext_v2f32_v2f64_unmasked: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, mu | ||
; CHECK-NEXT: vfwcvt.f.f.v v9, v8 | ||
; CHECK-NEXT: vmv1r.v v8, v9 | ||
; CHECK-NEXT: ret | ||
%v = call <2 x double> @llvm.vp.fpext.v2f64.v2f32(<2 x float> %a, <2 x i1> shufflevector (<2 x i1> insertelement (<2 x i1> undef, i1 true, i32 0), <2 x i1> undef, <2 x i32> zeroinitializer), i32 %vl) | ||
ret <2 x double> %v | ||
} |
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,77 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc -mtriple=riscv32 -mattr=+d,+zfh,+experimental-zvfh,+v -verify-machineinstrs < %s | FileCheck %s | ||
; RUN: llc -mtriple=riscv64 -mattr=+d,+zfh,+experimental-zvfh,+v -verify-machineinstrs < %s | FileCheck %s | ||
|
||
declare <vscale x 2 x float> @llvm.vp.fpext.nxv2f32.nxv2f16(<vscale x 2 x half>, <vscale x 2 x i1>, i32) | ||
|
||
define <vscale x 2 x float> @vfpext_nxv2f16_nxv2f32(<vscale x 2 x half> %a, <vscale x 2 x i1> %m, i32 zeroext %vl) { | ||
; CHECK-LABEL: vfpext_nxv2f16_nxv2f32: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: vsetvli zero, a0, e16, mf2, ta, mu | ||
; CHECK-NEXT: vfwcvt.f.f.v v9, v8, v0.t | ||
; CHECK-NEXT: vmv1r.v v8, v9 | ||
; CHECK-NEXT: ret | ||
%v = call <vscale x 2 x float> @llvm.vp.fpext.nxv2f32.nxv2f16(<vscale x 2 x half> %a, <vscale x 2 x i1> %m, i32 %vl) | ||
ret <vscale x 2 x float> %v | ||
} | ||
|
||
define <vscale x 2 x float> @vfpext_nxv2f16_nxv2f32_unmasked(<vscale x 2 x half> %a, i32 zeroext %vl) { | ||
; CHECK-LABEL: vfpext_nxv2f16_nxv2f32_unmasked: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: vsetvli zero, a0, e16, mf2, ta, mu | ||
; CHECK-NEXT: vfwcvt.f.f.v v9, v8 | ||
; CHECK-NEXT: vmv1r.v v8, v9 | ||
; CHECK-NEXT: ret | ||
%v = call <vscale x 2 x float> @llvm.vp.fpext.nxv2f32.nxv2f16(<vscale x 2 x half> %a, <vscale x 2 x i1> shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> undef, i1 true, i32 0), <vscale x 2 x i1> undef, <vscale x 2 x i32> zeroinitializer), i32 %vl) | ||
ret <vscale x 2 x float> %v | ||
} | ||
|
||
declare <vscale x 2 x double> @llvm.vp.fpext.nxv2f64.nxv2f16(<vscale x 2 x half>, <vscale x 2 x i1>, i32) | ||
|
||
define <vscale x 2 x double> @vfpext_nxv2f16_nxv2f64(<vscale x 2 x half> %a, <vscale x 2 x i1> %m, i32 zeroext %vl) { | ||
; CHECK-LABEL: vfpext_nxv2f16_nxv2f64: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: vsetvli zero, a0, e16, mf2, ta, mu | ||
; CHECK-NEXT: vfwcvt.f.f.v v10, v8, v0.t | ||
; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, mu | ||
; CHECK-NEXT: vfwcvt.f.f.v v8, v10, v0.t | ||
; CHECK-NEXT: ret | ||
%v = call <vscale x 2 x double> @llvm.vp.fpext.nxv2f64.nxv2f16(<vscale x 2 x half> %a, <vscale x 2 x i1> %m, i32 %vl) | ||
ret <vscale x 2 x double> %v | ||
} | ||
|
||
define <vscale x 2 x double> @vfpext_nxv2f16_nxv2f64_unmasked(<vscale x 2 x half> %a, i32 zeroext %vl) { | ||
; CHECK-LABEL: vfpext_nxv2f16_nxv2f64_unmasked: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: vsetvli zero, a0, e16, mf2, ta, mu | ||
; CHECK-NEXT: vfwcvt.f.f.v v10, v8 | ||
; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, mu | ||
; CHECK-NEXT: vfwcvt.f.f.v v8, v10 | ||
; CHECK-NEXT: ret | ||
%v = call <vscale x 2 x double> @llvm.vp.fpext.nxv2f64.nxv2f16(<vscale x 2 x half> %a, <vscale x 2 x i1> shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> undef, i1 true, i32 0), <vscale x 2 x i1> undef, <vscale x 2 x i32> zeroinitializer), i32 %vl) | ||
ret <vscale x 2 x double> %v | ||
} | ||
|
||
declare <vscale x 2 x double> @llvm.vp.fpext.nxv2f64.nxv2f32(<vscale x 2 x float>, <vscale x 2 x i1>, i32) | ||
|
||
define <vscale x 2 x double> @vfpext_nxv2f32_nxv2f64(<vscale x 2 x float> %a, <vscale x 2 x i1> %m, i32 zeroext %vl) { | ||
; CHECK-LABEL: vfpext_nxv2f32_nxv2f64: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, mu | ||
; CHECK-NEXT: vfwcvt.f.f.v v10, v8, v0.t | ||
; CHECK-NEXT: vmv2r.v v8, v10 | ||
; CHECK-NEXT: ret | ||
%v = call <vscale x 2 x double> @llvm.vp.fpext.nxv2f64.nxv2f32(<vscale x 2 x float> %a, <vscale x 2 x i1> %m, i32 %vl) | ||
ret <vscale x 2 x double> %v | ||
} | ||
|
||
define <vscale x 2 x double> @vfpext_nxv2f32_nxv2f64_unmasked(<vscale x 2 x float> %a, i32 zeroext %vl) { | ||
; CHECK-LABEL: vfpext_nxv2f32_nxv2f64_unmasked: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, mu | ||
; CHECK-NEXT: vfwcvt.f.f.v v10, v8 | ||
; CHECK-NEXT: vmv2r.v v8, v10 | ||
; CHECK-NEXT: ret | ||
%v = call <vscale x 2 x double> @llvm.vp.fpext.nxv2f64.nxv2f32(<vscale x 2 x float> %a, <vscale x 2 x i1> shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> undef, i1 true, i32 0), <vscale x 2 x i1> undef, <vscale x 2 x i32> zeroinitializer), i32 %vl) | ||
ret <vscale x 2 x double> %v | ||
} |