Skip to content

Commit b00fdde

Browse files
committed
[RISCV] Add test cases for failures to form widening FMA instructions. NFC
If the fp_extend is in the scalar domain before the shuffle, we won't recognize the widening opportunity.
1 parent 0dbd72d commit b00fdde

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

llvm/test/CodeGen/RISCV/rvv/fixed-vectors-vfwmacc.ll

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,3 +2027,75 @@ define <8 x double> @vfwnmsac_fv_v8f64_v8f16(<8 x double> %va, <8 x half> %vb, h
20272027
%vg = call <8 x double> @llvm.fma.v8f64(<8 x double> %vd, <8 x double> %vf, <8 x double> %va)
20282028
ret <8 x double> %vg
20292029
}
2030+
2031+
define <2 x float> @vfwmacc_vf2_v2f32(<2 x float> %va, <2 x half> %vb, half %c) {
2032+
; CHECK-LABEL: vfwmacc_vf2_v2f32:
2033+
; CHECK: # %bb.0:
2034+
; CHECK-NEXT: fcvt.s.h fa5, fa0
2035+
; CHECK-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
2036+
; CHECK-NEXT: vfwcvt.f.f.v v10, v9
2037+
; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma
2038+
; CHECK-NEXT: vfmacc.vf v8, fa5, v10
2039+
; CHECK-NEXT: ret
2040+
%cext = fpext half %c to float
2041+
%head = insertelement <2 x float> poison, float %cext, i32 0
2042+
%splat = shufflevector <2 x float> %head, <2 x float> poison, <2 x i32> zeroinitializer
2043+
%vd = fpext <2 x half> %vb to <2 x float>
2044+
%vf = call <2 x float> @llvm.fma.v2f32(<2 x float> %vd, <2 x float> %splat, <2 x float> %va)
2045+
ret <2 x float> %vf
2046+
}
2047+
2048+
define <2 x float> @vfwmsac_vf2_v2f32(<2 x float> %va, <2 x half> %vb, half %c) {
2049+
; CHECK-LABEL: vfwmsac_vf2_v2f32:
2050+
; CHECK: # %bb.0:
2051+
; CHECK-NEXT: fcvt.s.h fa5, fa0
2052+
; CHECK-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
2053+
; CHECK-NEXT: vfwcvt.f.f.v v10, v9
2054+
; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma
2055+
; CHECK-NEXT: vfmsac.vf v8, fa5, v10
2056+
; CHECK-NEXT: ret
2057+
%cext = fpext half %c to float
2058+
%head = insertelement <2 x float> poison, float %cext, i32 0
2059+
%splat = shufflevector <2 x float> %head, <2 x float> poison, <2 x i32> zeroinitializer
2060+
%vd = fpext <2 x half> %vb to <2 x float>
2061+
%ve = fneg <2 x float> %va
2062+
%vf = call <2 x float> @llvm.fma.v2f32(<2 x float> %vd, <2 x float> %splat, <2 x float> %ve)
2063+
ret <2 x float> %vf
2064+
}
2065+
2066+
define <2 x float> @vfwnmacc_vf2_v2f32(<2 x float> %va, <2 x half> %vb, half %c) {
2067+
; CHECK-LABEL: vfwnmacc_vf2_v2f32:
2068+
; CHECK: # %bb.0:
2069+
; CHECK-NEXT: fcvt.s.h fa5, fa0
2070+
; CHECK-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
2071+
; CHECK-NEXT: vfwcvt.f.f.v v10, v9
2072+
; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma
2073+
; CHECK-NEXT: vfnmacc.vf v8, fa5, v10
2074+
; CHECK-NEXT: ret
2075+
%cext = fpext half %c to float
2076+
%head = insertelement <2 x float> poison, float %cext, i32 0
2077+
%splat = shufflevector <2 x float> %head, <2 x float> poison, <2 x i32> zeroinitializer
2078+
%vd = fpext <2 x half> %vb to <2 x float>
2079+
%vf = fneg <2 x float> %va
2080+
%vg = fneg <2 x float> %vd
2081+
%vh = call <2 x float> @llvm.fma.v2f32(<2 x float> %vg, <2 x float> %splat, <2 x float> %vf)
2082+
ret <2 x float> %vh
2083+
}
2084+
2085+
define <2 x float> @vfwnmsac_vf2_v2f32(<2 x float> %va, <2 x half> %vb, half %c) {
2086+
; CHECK-LABEL: vfwnmsac_vf2_v2f32:
2087+
; CHECK: # %bb.0:
2088+
; CHECK-NEXT: fcvt.s.h fa5, fa0
2089+
; CHECK-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
2090+
; CHECK-NEXT: vfwcvt.f.f.v v10, v9
2091+
; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma
2092+
; CHECK-NEXT: vfnmsac.vf v8, fa5, v10
2093+
; CHECK-NEXT: ret
2094+
%cext = fpext half %c to float
2095+
%head = insertelement <2 x float> poison, float %cext, i32 0
2096+
%splat = shufflevector <2 x float> %head, <2 x float> poison, <2 x i32> zeroinitializer
2097+
%vd = fpext <2 x half> %vb to <2 x float>
2098+
%vf = fneg <2 x float> %vd
2099+
%vg = call <2 x float> @llvm.fma.v2f32(<2 x float> %vf, <2 x float> %splat, <2 x float> %va)
2100+
ret <2 x float> %vg
2101+
}

0 commit comments

Comments
 (0)