diff options
Diffstat (limited to 'llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-buildvec.ll')
| -rw-r--r-- | llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-buildvec.ll | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-buildvec.ll b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-buildvec.ll index 3c3e08d387fa..248ec1369076 100644 --- a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-buildvec.ll +++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-buildvec.ll @@ -1828,3 +1828,160 @@ define <8 x double> @buildvec_v8f64_zvl512(double %e0, double %e1, double %e2, d %v7 = insertelement <8 x double> %v6, double %e7, i64 7 ret <8 x double> %v7 } + +define <4 x float> @buildvec_vfredusum_slideup(float %start, <8 x float> %arg1, <8 x float> %arg2, <8 x float> %arg3, <8 x float> %arg4) nounwind { +; CHECK-LABEL: buildvec_vfredusum_slideup: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma +; CHECK-NEXT: vfmv.s.f v16, fa0 +; CHECK-NEXT: vfredusum.vs v8, v8, v16 +; CHECK-NEXT: vfredusum.vs v9, v10, v16 +; CHECK-NEXT: vfredusum.vs v10, v12, v16 +; CHECK-NEXT: vfredusum.vs v11, v14, v16 +; CHECK-NEXT: vsetivli zero, 4, e32, m1, tu, ma +; CHECK-NEXT: vslideup.vi v10, v11, 1 +; CHECK-NEXT: vslideup.vi v9, v10, 1 +; CHECK-NEXT: vslideup.vi v8, v9, 1 +; CHECK-NEXT: ret + %247 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg1) + %248 = insertelement <4 x float> poison, float %247, i64 0 + %250 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg2) + %251 = insertelement <4 x float> %248, float %250, i64 1 + %252 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg3) + %253 = insertelement <4 x float> %251, float %252, i64 2 + %254 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg4) + %255 = insertelement <4 x float> %253, float %254, i64 3 + ret <4 x float> %255 +} + +define <8 x float> @buildvec_vfredusum_slideup_leading_undef(float %start, <8 x float> %arg1, <8 x float> %arg2, <8 x float> %arg3, <8 x float> %arg4) nounwind { +; CHECK-LABEL: buildvec_vfredusum_slideup_leading_undef: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma +; CHECK-NEXT: vfmv.s.f v17, fa0 +; CHECK-NEXT: vfredusum.vs v16, v8, v17 +; CHECK-NEXT: vfredusum.vs v8, v10, v17 +; CHECK-NEXT: vfredusum.vs v10, v12, v17 +; CHECK-NEXT: vfredusum.vs v12, v14, v17 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, tu, ma +; CHECK-NEXT: vslideup.vi v10, v12, 1 +; CHECK-NEXT: vslideup.vi v8, v10, 1 +; CHECK-NEXT: vslideup.vi v16, v8, 1 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma +; CHECK-NEXT: vslideup.vi v8, v16, 4 +; CHECK-NEXT: ret + %252 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg1) + %253 = insertelement <8 x float> poison, float %252, i64 4 + %254 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg2) + %255 = insertelement <8 x float> %253, float %254, i64 5 + %256 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg3) + %257 = insertelement <8 x float> %255, float %256, i64 6 + %258 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg4) + %259 = insertelement <8 x float> %257, float %258, i64 7 + ret <8 x float> %259 +} + +define <8 x float> @buildvec_vfredusum_slideup_trailing_undef(float %start, <8 x float> %arg1, <8 x float> %arg2, <8 x float> %arg3, <8 x float> %arg4) nounwind { +; CHECK-LABEL: buildvec_vfredusum_slideup_trailing_undef: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma +; CHECK-NEXT: vfmv.s.f v16, fa0 +; CHECK-NEXT: vfredusum.vs v8, v8, v16 +; CHECK-NEXT: vfredusum.vs v10, v10, v16 +; CHECK-NEXT: vfredusum.vs v12, v12, v16 +; CHECK-NEXT: vfredusum.vs v14, v14, v16 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, tu, ma +; CHECK-NEXT: vslideup.vi v12, v14, 1 +; CHECK-NEXT: vslideup.vi v10, v12, 1 +; CHECK-NEXT: vslideup.vi v8, v10, 1 +; CHECK-NEXT: ret + %252 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg1) + %253 = insertelement <8 x float> poison, float %252, i64 0 + %254 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg2) + %255 = insertelement <8 x float> %253, float %254, i64 1 + %256 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg3) + %257 = insertelement <8 x float> %255, float %256, i64 2 + %258 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg4) + %259 = insertelement <8 x float> %257, float %258, i64 3 + ret <8 x float> %259 +} + +; Negative test case checking if we generate slideup only when all build_vec operands are extraction from the first vector element. +define <8 x float> @buildvec_vfredusum_slideup_not_extract_first(float %start, <8 x float> %arg1, <8 x float> %arg2, <8 x float> %arg3, <8 x float> %arg4) nounwind { +; CHECK-LABEL: buildvec_vfredusum_slideup_not_extract_first: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma +; CHECK-NEXT: vfmv.s.f v10, fa0 +; CHECK-NEXT: vfredusum.vs v8, v8, v10 +; CHECK-NEXT: vfredusum.vs v9, v12, v10 +; CHECK-NEXT: vfredusum.vs v10, v14, v10 +; CHECK-NEXT: vfmv.f.s fa5, v9 +; CHECK-NEXT: vfmv.f.s fa4, v10 +; CHECK-NEXT: vrgather.vi v10, v8, 0 +; CHECK-NEXT: vfslide1down.vf v8, v10, fa0 +; CHECK-NEXT: vfslide1down.vf v8, v8, fa5 +; CHECK-NEXT: vfslide1down.vf v8, v8, fa4 +; CHECK-NEXT: vslidedown.vi v8, v8, 4 +; CHECK-NEXT: ret + %252 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg1) + %253 = insertelement <8 x float> poison, float %252, i64 0 + %255 = insertelement <8 x float> %253, float %start, i64 1 + %256 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg3) + %257 = insertelement <8 x float> %255, float %256, i64 2 + %258 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg4) + %259 = insertelement <8 x float> %257, float %258, i64 3 + ret <8 x float> %259 +} + +define <8 x float> @buildvec_vfredusum_slideup_mid_undef(float %start, <8 x float> %arg1, <8 x float> %arg2, <8 x float> %arg3, <8 x float> %arg4) nounwind { +; CHECK-LABEL: buildvec_vfredusum_slideup_mid_undef: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma +; CHECK-NEXT: vfmv.s.f v16, fa0 +; CHECK-NEXT: vfredusum.vs v8, v8, v16 +; CHECK-NEXT: vfredusum.vs v10, v10, v16 +; CHECK-NEXT: vfredusum.vs v12, v12, v16 +; CHECK-NEXT: vfredusum.vs v14, v14, v16 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, tu, ma +; CHECK-NEXT: vslideup.vi v12, v14, 1 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma +; CHECK-NEXT: vslideup.vi v14, v12, 4 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, tu, ma +; CHECK-NEXT: vslideup.vi v10, v14, 1 +; CHECK-NEXT: vslideup.vi v8, v10, 1 +; CHECK-NEXT: ret + %252 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg1) + %253 = insertelement <8 x float> poison, float %252, i64 0 + %254 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg2) + %255 = insertelement <8 x float> %253, float %254, i64 1 + %256 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg3) + %257 = insertelement <8 x float> %255, float %256, i64 6 + %258 = tail call reassoc float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg4) + %259 = insertelement <8 x float> %257, float %258, i64 7 + ret <8 x float> %259 +} + +define <4 x float> @buildvec_vfredosum_slideup(float %start, <8 x float> %arg1, <8 x float> %arg2, <8 x float> %arg3, <8 x float> %arg4) nounwind { +; CHECK-LABEL: buildvec_vfredosum_slideup: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma +; CHECK-NEXT: vfmv.s.f v16, fa0 +; CHECK-NEXT: vfredosum.vs v8, v8, v16 +; CHECK-NEXT: vfredosum.vs v9, v10, v16 +; CHECK-NEXT: vfredosum.vs v10, v12, v16 +; CHECK-NEXT: vfredosum.vs v11, v14, v16 +; CHECK-NEXT: vsetivli zero, 4, e32, m1, tu, ma +; CHECK-NEXT: vslideup.vi v10, v11, 1 +; CHECK-NEXT: vslideup.vi v9, v10, 1 +; CHECK-NEXT: vslideup.vi v8, v9, 1 +; CHECK-NEXT: ret + %247 = tail call float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg1) + %248 = insertelement <4 x float> poison, float %247, i64 0 + %250 = tail call float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg2) + %251 = insertelement <4 x float> %248, float %250, i64 1 + %252 = tail call float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg3) + %253 = insertelement <4 x float> %251, float %252, i64 2 + %254 = tail call float @llvm.vector.reduce.fadd.v8f32(float %start, <8 x float> %arg4) + %255 = insertelement <4 x float> %253, float %254, i64 3 + ret <4 x float> %255 +} |
