; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py ; RUN: llc -mtriple=riscv32 -mattr=+d,+experimental-zfh,+experimental-v -target-abi=ilp32d \ ; RUN: -verify-machineinstrs < %s | FileCheck %s ; RUN: llc -mtriple=riscv64 -mattr=+d,+experimental-zfh,+experimental-v -target-abi=lp64d \ ; RUN: -verify-machineinstrs < %s | FileCheck %s ; This tests a mix of vfnmsac and vfnmsub by using different operand orders to ; trigger commuting in TwoAddressInstructionPass. declare @llvm.fma.v1f16(, , ) define @vfnmsub_vv_nxv1f16( %va, %vb, %vc) { ; CHECK-LABEL: vfnmsub_vv_nxv1f16: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, mu ; CHECK-NEXT: vfnmsub.vv v8, v9, v10 ; CHECK-NEXT: ret %neg = fneg %va %vd = call @llvm.fma.v1f16( %neg, %vb, %vc) ret %vd } define @vfnmsub_vf_nxv1f16( %va, %vb, half %c) { ; CHECK-LABEL: vfnmsub_vf_nxv1f16: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, mu ; CHECK-NEXT: vfnmsub.vf v8, fa0, v9 ; CHECK-NEXT: ret %head = insertelement undef, half %c, i32 0 %splat = shufflevector %head, undef, zeroinitializer %neg = fneg %va %vd = call @llvm.fma.v1f16( %neg, %splat, %vb) ret %vd } declare @llvm.fma.v2f16(, , ) define @vfnmsub_vv_nxv2f16( %va, %vb, %vc) { ; CHECK-LABEL: vfnmsub_vv_nxv2f16: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, mu ; CHECK-NEXT: vfnmsub.vv v8, v10, v9 ; CHECK-NEXT: ret %neg = fneg %va %vd = call @llvm.fma.v2f16( %neg, %vc, %vb) ret %vd } define @vfnmsub_vf_nxv2f16( %va, %vb, half %c) { ; CHECK-LABEL: vfnmsub_vf_nxv2f16: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, mu ; CHECK-NEXT: vfnmsub.vf v8, fa0, v9 ; CHECK-NEXT: ret %head = insertelement undef, half %c, i32 0 %splat = shufflevector %head, undef, zeroinitializer %neg = fneg %va %vd = call @llvm.fma.v2f16( %splat, %neg, %vb) ret %vd } declare @llvm.fma.v4f16(, , ) define @vfnmsub_vv_nxv4f16( %va, %vb, %vc) { ; CHECK-LABEL: vfnmsub_vv_nxv4f16: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, mu ; CHECK-NEXT: vfnmsub.vv v8, v9, v10 ; CHECK-NEXT: ret %neg = fneg %vb %vd = call @llvm.fma.v4f16( %neg, %va, %vc) ret %vd } define @vfnmsub_vf_nxv4f16( %va, %vb, half %c) { ; CHECK-LABEL: vfnmsub_vf_nxv4f16: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, mu ; CHECK-NEXT: vfnmsub.vf v8, fa0, v9 ; CHECK-NEXT: ret %head = insertelement undef, half %c, i32 0 %splat = shufflevector %head, undef, zeroinitializer %neg = fneg %splat %vd = call @llvm.fma.v4f16( %va, %neg, %vb) ret %vd } declare @llvm.fma.v8f16(, , ) define @vfnmsub_vv_nxv8f16( %va, %vb, %vc) { ; CHECK-LABEL: vfnmsub_vv_nxv8f16: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, mu ; CHECK-NEXT: vfnmsac.vv v8, v12, v10 ; CHECK-NEXT: ret %neg = fneg %vb %vd = call @llvm.fma.v8f16( %neg, %vc, %va) ret %vd } define @vfnmsub_vf_nxv8f16( %va, %vb, half %c) { ; CHECK-LABEL: vfnmsub_vf_nxv8f16: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, mu ; CHECK-NEXT: vfnmsac.vf v8, fa0, v10 ; CHECK-NEXT: ret %head = insertelement undef, half %c, i32 0 %splat = shufflevector %head, undef, zeroinitializer %neg = fneg %splat %vd = call @llvm.fma.v8f16( %vb, %neg, %va) ret %vd } declare @llvm.fma.v16f16(, , ) define @vfnmsub_vv_nxv16f16( %va, %vb, %vc) { ; CHECK-LABEL: vfnmsub_vv_nxv16f16: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, mu ; CHECK-NEXT: vfnmsub.vv v8, v16, v12 ; CHECK-NEXT: ret %neg = fneg %vc %vd = call @llvm.fma.v16f16( %neg, %va, %vb) ret %vd } define @vfnmsub_vf_nxv16f16( %va, %vb, half %c) { ; CHECK-LABEL: vfnmsub_vf_nxv16f16: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, mu ; CHECK-NEXT: vfnmsub.vf v8, fa0, v12 ; CHECK-NEXT: ret %head = insertelement undef, half %c, i32 0 %splat = shufflevector %head, undef, zeroinitializer %neg = fneg %splat %vd = call @llvm.fma.v16f16( %neg, %va, %vb) ret %vd } declare @llvm.fma.v32f16(, , ) define @vfnmsub_vv_nxv32f16( %va, %vb, %vc) { ; CHECK-LABEL: vfnmsub_vv_nxv32f16: ; CHECK: # %bb.0: ; CHECK-NEXT: vl8re16.v v24, (a0) ; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, mu ; CHECK-NEXT: vfnmsub.vv v8, v24, v16 ; CHECK-NEXT: ret %neg = fneg %vc %vd = call @llvm.fma.v32f16( %neg, %va, %vb) ret %vd } define @vfnmsub_vf_nxv32f16( %va, %vb, half %c) { ; CHECK-LABEL: vfnmsub_vf_nxv32f16: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, mu ; CHECK-NEXT: vfnmsac.vf v8, fa0, v16 ; CHECK-NEXT: ret %head = insertelement undef, half %c, i32 0 %splat = shufflevector %head, undef, zeroinitializer %neg = fneg %splat %vd = call @llvm.fma.v32f16( %neg, %vb, %va) ret %vd } declare @llvm.fma.v1f32(, , ) define @vfnmsub_vv_nxv1f32( %va, %vb, %vc) { ; CHECK-LABEL: vfnmsub_vv_nxv1f32: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, mu ; CHECK-NEXT: vfnmsub.vv v8, v9, v10 ; CHECK-NEXT: ret %neg = fneg %vb %vd = call @llvm.fma.v1f32( %va, %neg, %vc) ret %vd } define @vfnmsub_vf_nxv1f32( %va, %vb, float %c) { ; CHECK-LABEL: vfnmsub_vf_nxv1f32: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, mu ; CHECK-NEXT: vfnmsub.vf v8, fa0, v9 ; CHECK-NEXT: ret %head = insertelement undef, float %c, i32 0 %splat = shufflevector %head, undef, zeroinitializer %neg = fneg %va %vd = call @llvm.fma.v1f32( %neg, %splat, %vb) ret %vd } declare @llvm.fma.v2f32(, , ) define @vfnmsub_vv_nxv2f32( %va, %vb, %vc) { ; CHECK-LABEL: vfnmsub_vv_nxv2f32: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, mu ; CHECK-NEXT: vfnmsub.vv v8, v10, v9 ; CHECK-NEXT: ret %neg = fneg %vc %vd = call @llvm.fma.v2f32( %va, %neg, %vb) ret %vd } define @vfnmsub_vf_nxv2f32( %va, %vb, float %c) { ; CHECK-LABEL: vfnmsub_vf_nxv2f32: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, mu ; CHECK-NEXT: vfnmsub.vf v8, fa0, v9 ; CHECK-NEXT: ret %head = insertelement undef, float %c, i32 0 %splat = shufflevector %head, undef, zeroinitializer %neg = fneg %va %vd = call @llvm.fma.v2f32( %splat, %neg, %vb) ret %vd } declare @llvm.fma.v4f32(, , ) define @vfnmsub_vv_nxv4f32( %va, %vb, %vc) { ; CHECK-LABEL: vfnmsub_vv_nxv4f32: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, mu ; CHECK-NEXT: vfnmsub.vv v8, v10, v12 ; CHECK-NEXT: ret %neg = fneg %va %vd = call @llvm.fma.v4f32( %vb, %neg, %vc) ret %vd } define @vfnmsub_vf_nxv4f32( %va, %vb, float %c) { ; CHECK-LABEL: vfnmsub_vf_nxv4f32: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, mu ; CHECK-NEXT: vfnmsub.vf v8, fa0, v10 ; CHECK-NEXT: ret %head = insertelement undef, float %c, i32 0 %splat = shufflevector %head, undef, zeroinitializer %neg = fneg %splat %vd = call @llvm.fma.v4f32( %va, %neg, %vb) ret %vd } declare @llvm.fma.v8f32(, , ) define @vfnmsub_vv_nxv8f32( %va, %vb, %vc) { ; CHECK-LABEL: vfnmsub_vv_nxv8f32: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu ; CHECK-NEXT: vfnmsac.vv v8, v16, v12 ; CHECK-NEXT: ret %neg = fneg %vc %vd = call @llvm.fma.v8f32( %vb, %neg, %va) ret %vd } define @vfnmsub_vf_nxv8f32( %va, %vb, float %c) { ; CHECK-LABEL: vfnmsub_vf_nxv8f32: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu ; CHECK-NEXT: vfnmsac.vf v8, fa0, v12 ; CHECK-NEXT: ret %head = insertelement undef, float %c, i32 0 %splat = shufflevector %head, undef, zeroinitializer %neg = fneg %splat %vd = call @llvm.fma.v8f32( %vb, %neg, %va) ret %vd } declare @llvm.fma.v16f32(, , ) define @vfnmsub_vv_nxv16f32( %va, %vb, %vc) { ; CHECK-LABEL: vfnmsub_vv_nxv16f32: ; CHECK: # %bb.0: ; CHECK-NEXT: vl8re32.v v24, (a0) ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, mu ; CHECK-NEXT: vfnmsub.vv v8, v24, v16 ; CHECK-NEXT: ret %neg = fneg %va %vd = call @llvm.fma.v16f32( %vc, %neg, %vb) ret %vd } define @vfnmsub_vf_nxv16f32( %va, %vb, float %c) { ; CHECK-LABEL: vfnmsub_vf_nxv16f32: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, mu ; CHECK-NEXT: vfnmsub.vf v8, fa0, v16 ; CHECK-NEXT: ret %head = insertelement undef, float %c, i32 0 %splat = shufflevector %head, undef, zeroinitializer %neg = fneg %splat %vd = call @llvm.fma.v16f32( %neg, %va, %vb) ret %vd } declare @llvm.fma.v1f64(, , ) define @vfnmsub_vv_nxv1f64( %va, %vb, %vc) { ; CHECK-LABEL: vfnmsub_vv_nxv1f64: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, mu ; CHECK-NEXT: vfnmsac.vv v8, v10, v9 ; CHECK-NEXT: ret %neg = fneg %vb %vd = call @llvm.fma.v1f64( %vc, %neg, %va) ret %vd } define @vfnmsub_vf_nxv1f64( %va, %vb, double %c) { ; CHECK-LABEL: vfnmsub_vf_nxv1f64: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, mu ; CHECK-NEXT: vfnmsub.vf v8, fa0, v9 ; CHECK-NEXT: ret %head = insertelement undef, double %c, i32 0 %splat = shufflevector %head, undef, zeroinitializer %neg = fneg %va %vd = call @llvm.fma.v1f64( %neg, %splat, %vb) ret %vd } declare @llvm.fma.v2f64(, , ) define @vfnmsub_vv_nxv2f64( %va, %vb, %vc) { ; CHECK-LABEL: vfnmsub_vv_nxv2f64: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, mu ; CHECK-NEXT: vfnmsub.vv v8, v12, v10 ; CHECK-NEXT: ret %neg = fneg %va %vd = call @llvm.fma.v2f64( %neg, %vc, %vb) ret %vd } define @vfnmsub_vf_nxv2f64( %va, %vb, double %c) { ; CHECK-LABEL: vfnmsub_vf_nxv2f64: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, mu ; CHECK-NEXT: vfnmsub.vf v8, fa0, v10 ; CHECK-NEXT: ret %head = insertelement undef, double %c, i32 0 %splat = shufflevector %head, undef, zeroinitializer %neg = fneg %va %vd = call @llvm.fma.v2f64( %splat, %neg, %vb) ret %vd } declare @llvm.fma.v4f64(, , ) define @vfnmsub_vv_nxv4f64( %va, %vb, %vc) { ; CHECK-LABEL: vfnmsub_vv_nxv4f64: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, mu ; CHECK-NEXT: vfnmsub.vv v8, v12, v16 ; CHECK-NEXT: ret %neg = fneg %vb %vd = call @llvm.fma.v4f64( %neg, %va, %vc) ret %vd } define @vfnmsub_vf_nxv4f64( %va, %vb, double %c) { ; CHECK-LABEL: vfnmsub_vf_nxv4f64: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, mu ; CHECK-NEXT: vfnmsub.vf v8, fa0, v12 ; CHECK-NEXT: ret %head = insertelement undef, double %c, i32 0 %splat = shufflevector %head, undef, zeroinitializer %neg = fneg %splat %vd = call @llvm.fma.v4f64( %va, %neg, %vb) ret %vd } declare @llvm.fma.v8f64(, , ) define @vfnmsub_vv_nxv8f64( %va, %vb, %vc) { ; CHECK-LABEL: vfnmsub_vv_nxv8f64: ; CHECK: # %bb.0: ; CHECK-NEXT: vl8re64.v v24, (a0) ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, mu ; CHECK-NEXT: vfnmsac.vv v8, v16, v24 ; CHECK-NEXT: ret %neg = fneg %vb %vd = call @llvm.fma.v8f64( %neg, %vc, %va) ret %vd } define @vfnmsub_vf_nxv8f64( %va, %vb, double %c) { ; CHECK-LABEL: vfnmsub_vf_nxv8f64: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, mu ; CHECK-NEXT: vfnmsac.vf v8, fa0, v16 ; CHECK-NEXT: ret %head = insertelement undef, double %c, i32 0 %splat = shufflevector %head, undef, zeroinitializer %neg = fneg %splat %vd = call @llvm.fma.v8f64( %vb, %neg, %va) ret %vd }