diff --git a/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vfmadd_d.c b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vfmadd_d.c
new file mode 100644
index 00000000000..c5de1ac7ae9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vfmadd_d.c
@@ -0,0 +1,251 @@
+/* { dg-do run } */
+/* { dg-options "-mlsx -w -fno-strict-aliasing" } */
+#include "../simd_correctness_check.h"
+#include <lsxintrin.h>
+
+int
+main ()
+{
+  __m128i __m128i_op0, __m128i_op1, __m128i_op2, __m128i_out, __m128i_result;
+  __m128 __m128_op0, __m128_op1, __m128_op2, __m128_out, __m128_result;
+  __m128d __m128d_op0, __m128d_op1, __m128d_op2, __m128d_out, __m128d_result;
+
+  int int_op0, int_op1, int_op2, int_out, int_result, i = 1, fail;
+  long int long_op0, long_op1, long_op2, lont_out, lont_result;
+  long int long_int_out, long_int_result;
+  unsigned int unsigned_int_out, unsigned_int_result;
+  unsigned long int unsigned_long_int_out, unsigned_long_int_result;
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0x8a228acac14e440a;
+  *((unsigned long *)&__m128d_op1[0]) = 0xc77c47cdc0f16549;
+  *((unsigned long *)&__m128d_op2[1]) = 0xffffffffd24271c4;
+  *((unsigned long *)&__m128d_op2[0]) = 0x2711bad1e8e309ed;
+  *((unsigned long *)&__m128d_result[1]) = 0xffffffffd24271c4;
+  *((unsigned long *)&__m128d_result[0]) = 0x2711bad1e8e309ed;
+  __m128d_out = __lsx_vfmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_op1[0]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_op2[1]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_op2[0]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_result[1]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_result[0]) = 0xffffffffffffffff;
+  __m128d_out = __lsx_vfmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000040400000383;
+  *((unsigned long *)&__m128d_op0[0]) = 0xffffe000ffff1fff;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000040400000383;
+  *((unsigned long *)&__m128d_op1[0]) = 0xffffe000ffff1fff;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000001000001;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0001000100000000;
+  *((unsigned long *)&__m128d_result[1]) = 0x0000000001000001;
+  *((unsigned long *)&__m128d_result[0]) = 0xffffe000ffff1fff;
+  __m128d_out = __lsx_vfmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0x00000000003f80b0;
+  *((unsigned long *)&__m128d_op1[0]) = 0x00000000ff800000;
+  *((unsigned long *)&__m128d_op2[1]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_op2[0]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_result[1]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_result[0]) = 0xffffffffffffffff;
+  __m128d_out = __lsx_vfmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0080200000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000401000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000080000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000080000000000;
+  *((unsigned long *)&__m128d_result[1]) = 0x0000080000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0x0000080000000000;
+  __m128d_out = __lsx_vfmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0x0000000000000000;
+  __m128d_out = __lsx_vfmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x000000000000001e;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0x0000000000000000;
+  __m128d_out = __lsx_vfmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_op0[0]) = 0x7fff7fff7fff7fff;
+  *((unsigned long *)&__m128d_op1[1]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_op1[0]) = 0x3fff3fff3fff3fff;
+  *((unsigned long *)&__m128d_op2[1]) = 0xfffb00fdfdf7ffff;
+  *((unsigned long *)&__m128d_op2[0]) = 0xfff8000000000000;
+  *((unsigned long *)&__m128d_result[1]) = 0xfffb00fdfdf7ffff;
+  *((unsigned long *)&__m128d_result[0]) = 0xfff8000000000000;
+  __m128d_out = __lsx_vfmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x8000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x8000000000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000009000900;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000009000900;
+  *((unsigned long *)&__m128d_result[1]) = 0x0000000009000900;
+  *((unsigned long *)&__m128d_result[0]) = 0x0000000009000900;
+  __m128d_out = __lsx_vfmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000200000002;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0000000200000002;
+  *((unsigned long *)&__m128d_op2[1]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_op2[0]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_result[1]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_result[0]) = 0xffffffffffffffff;
+  __m128d_out = __lsx_vfmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x9c83e21a22001818;
+  *((unsigned long *)&__m128d_op0[0]) = 0xdd3b8b02563b2d7b;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x7f7f7f007f7f7f00;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x7f7f7f007f7f7f00;
+  *((unsigned long *)&__m128d_result[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0xfff0000000000000;
+  __m128d_out = __lsx_vfmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0xff00e400ff00e400;
+  *((unsigned long *)&__m128d_op0[0]) = 0xff01e41ffff0ffff;
+  *((unsigned long *)&__m128d_op1[1]) = 0x5555000054100000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x5555000154100155;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[1]) = 0xfff0000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0xfff0000000000000;
+  __m128d_out = __lsx_vfmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000000000010;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000000000010;
+  *((unsigned long *)&__m128d_result[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0x8000000000000010;
+  __m128d_out = __lsx_vfmsub_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0xfc01fcfefc02fdf7;
+  *((unsigned long *)&__m128d_op0[0]) = 0xfe00fcfffe01fd01;
+  *((unsigned long *)&__m128d_op1[1]) = 0xfc01fd1300000001;
+  *((unsigned long *)&__m128d_op1[0]) = 0xfe00fd1400010000;
+  *((unsigned long *)&__m128d_op2[1]) = 0xfc01fcfefc02fdf7;
+  *((unsigned long *)&__m128d_op2[0]) = 0xfe00fcfffe01fd01;
+  *((unsigned long *)&__m128d_result[1]) = 0x7ff0000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0x7ff0000000000000;
+  __m128d_out = __lsx_vfmsub_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0000bd3d00000000;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0x0000000000000000;
+  __m128d_out = __lsx_vfmsub_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0038d800ff000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x00fffe00fffffe00;
+  *((unsigned long *)&__m128d_op2[1]) = 0x8000008000008080;
+  *((unsigned long *)&__m128d_op2[0]) = 0x8080800000800080;
+  *((unsigned long *)&__m128d_result[1]) = 0x0000008000008080;
+  *((unsigned long *)&__m128d_result[0]) = 0xffffffffffffffff;
+  __m128d_out = __lsx_vfmsub_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0x0000000000000000;
+  __m128d_out = __lsx_vfmsub_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x00ff80ff00ff80ff;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000900000009;
+  *((unsigned long *)&__m128d_result[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0xffffffffffffffff;
+  __m128d_out = __lsx_vfmsub_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x000000007ff000ff;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0x0000000000000000;
+  __m128d_out = __lsx_vfmsub_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0xffffff7ffffffffe;
+  *((unsigned long *)&__m128d_op0[0]) = 0x00000000fffffffe;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[1]) = 0xffffff7ffffffffe;
+  *((unsigned long *)&__m128d_result[0]) = 0x0000000000000000;
+  __m128d_out = __lsx_vfmsub_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0x67eb85afb2ebb000;
+  *((unsigned long *)&__m128d_op1[0]) = 0xc8847ef6ed3f2000;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000100000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000000000103;
+  *((unsigned long *)&__m128d_result[1]) = 0x8000000100000000;
+  *((unsigned long *)&__m128d_result[0]) = 0x8000000000000103;
+  __m128d_out = __lsx_vfmsub_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vfmadd_s.c b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vfmadd_s.c
new file mode 100644
index 00000000000..6b85e87bdce
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vfmadd_s.c
@@ -0,0 +1,381 @@
+/* { dg-do run } */
+/* { dg-options "-mlsx -w -fno-strict-aliasing" } */
+#include "../simd_correctness_check.h"
+#include <lsxintrin.h>
+
+int
+main ()
+{
+  __m128i __m128i_op0, __m128i_op1, __m128i_op2, __m128i_out, __m128i_result;
+  __m128 __m128_op0, __m128_op1, __m128_op2, __m128_out, __m128_result;
+  __m128d __m128d_op0, __m128d_op1, __m128d_op2, __m128d_out, __m128d_result;
+
+  int int_op0, int_op1, int_op2, int_out, int_result, i = 1, fail;
+  long int long_op0, long_op1, long_op2, lont_out, lont_result;
+  long int long_int_out, long_int_result;
+  unsigned int unsigned_int_out, unsigned_int_result;
+  unsigned long int unsigned_long_int_out, unsigned_long_int_result;
+
+  *((int *)&__m128_op0[3]) = 0x00000000;
+  *((int *)&__m128_op0[2]) = 0x00000000;
+  *((int *)&__m128_op0[1]) = 0x00000000;
+  *((int *)&__m128_op0[0]) = 0x00000000;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x00000002;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0x00000000;
+  *((int *)&__m128_result[2]) = 0x00000000;
+  *((int *)&__m128_result[1]) = 0x00000002;
+  *((int *)&__m128_result[0]) = 0x00000000;
+  __m128_out = __lsx_vfmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x0028e0a1;
+  *((int *)&__m128_op0[2]) = 0xa000a041;
+  *((int *)&__m128_op0[1]) = 0x01000041;
+  *((int *)&__m128_op0[0]) = 0x00010001;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x01000001;
+  *((int *)&__m128_op1[1]) = 0x00010001;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x01000001;
+  *((int *)&__m128_op2[1]) = 0xffffe000;
+  *((int *)&__m128_op2[0]) = 0xffff1fff;
+  *((int *)&__m128_result[3]) = 0x00000000;
+  *((int *)&__m128_result[2]) = 0x01000001;
+  *((int *)&__m128_result[1]) = 0xffffe000;
+  *((int *)&__m128_result[0]) = 0xffff1fff;
+  __m128_out = __lsx_vfmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x7f800000;
+  *((int *)&__m128_op0[2]) = 0x7f800000;
+  *((int *)&__m128_op0[1]) = 0x7f800000;
+  *((int *)&__m128_op0[0]) = 0x7f800000;
+  *((int *)&__m128_op1[3]) = 0x00000002;
+  *((int *)&__m128_op1[2]) = 0x00000002;
+  *((int *)&__m128_op1[1]) = 0x00000003;
+  *((int *)&__m128_op1[0]) = 0x00000003;
+  *((int *)&__m128_op2[3]) = 0x3fc00000;
+  *((int *)&__m128_op2[2]) = 0x3fc00000;
+  *((int *)&__m128_op2[1]) = 0x3fc00000;
+  *((int *)&__m128_op2[0]) = 0x3fc00000;
+  *((int *)&__m128_result[3]) = 0x7f800000;
+  *((int *)&__m128_result[2]) = 0x7f800000;
+  *((int *)&__m128_result[1]) = 0x7f800000;
+  *((int *)&__m128_result[0]) = 0x7f800000;
+  __m128_out = __lsx_vfmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0xc1bdceee;
+  *((int *)&__m128_op0[2]) = 0x242070db;
+  *((int *)&__m128_op0[1]) = 0xe8c7b756;
+  *((int *)&__m128_op0[0]) = 0xd76aa478;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x00000000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0x00000000;
+  *((int *)&__m128_result[2]) = 0x00000000;
+  *((int *)&__m128_result[1]) = 0x00000000;
+  *((int *)&__m128_result[0]) = 0x00000000;
+  __m128_out = __lsx_vfmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x7f400000;
+  *((int *)&__m128_op0[2]) = 0x7f040000;
+  *((int *)&__m128_op0[1]) = 0x7f020000;
+  *((int *)&__m128_op0[0]) = 0x7f020000;
+  *((int *)&__m128_op1[3]) = 0xffffffff;
+  *((int *)&__m128_op1[2]) = 0x0014002c;
+  *((int *)&__m128_op1[1]) = 0xfffefffe;
+  *((int *)&__m128_op1[0]) = 0x003b0013;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x00000000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0xffffffff;
+  *((int *)&__m128_result[2]) = 0x3ea5016b;
+  *((int *)&__m128_result[1]) = 0xfffefffe;
+  *((int *)&__m128_result[0]) = 0x3f6fb04d;
+  __m128_out = __lsx_vfmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x004f0080;
+  *((int *)&__m128_op0[2]) = 0x004f0080;
+  *((int *)&__m128_op0[1]) = 0x004f0080;
+  *((int *)&__m128_op0[0]) = 0x004f0080;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0x7fff7fff;
+  *((int *)&__m128_op2[2]) = 0x7fff7fff;
+  *((int *)&__m128_op2[1]) = 0x00000000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0x7fff7fff;
+  *((int *)&__m128_result[2]) = 0x7fff7fff;
+  *((int *)&__m128_result[1]) = 0x00000000;
+  *((int *)&__m128_result[0]) = 0x00000000;
+  __m128_out = __lsx_vfmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x3d3d3d3d;
+  *((int *)&__m128_op0[2]) = 0x3d3d3d3d;
+  *((int *)&__m128_op0[1]) = 0x3d3d3d3d;
+  *((int *)&__m128_op0[0]) = 0x3d3d3d3d;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x00100000;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x00000000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0x00000000;
+  *((int *)&__m128_result[2]) = 0x00000000;
+  *((int *)&__m128_result[1]) = 0x0000bd3d;
+  *((int *)&__m128_result[0]) = 0x00000000;
+  __m128_out = __lsx_vfmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00000000;
+  *((int *)&__m128_op0[2]) = 0x00000000;
+  *((int *)&__m128_op0[1]) = 0x00000000;
+  *((int *)&__m128_op0[0]) = 0x00000000;
+  *((int *)&__m128_op1[3]) = 0x00050005;
+  *((int *)&__m128_op1[2]) = 0x00050005;
+  *((int *)&__m128_op1[1]) = 0x00050005;
+  *((int *)&__m128_op1[0]) = 0x00050005;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x00000000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0x00000000;
+  *((int *)&__m128_result[2]) = 0x00000000;
+  *((int *)&__m128_result[1]) = 0x00000000;
+  *((int *)&__m128_result[0]) = 0x00000000;
+  __m128_out = __lsx_vfmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0xe500c085;
+  *((int *)&__m128_op0[2]) = 0xc000c005;
+  *((int *)&__m128_op0[1]) = 0xe5c1a185;
+  *((int *)&__m128_op0[0]) = 0xc48004c5;
+  *((int *)&__m128_op1[3]) = 0xffffffff;
+  *((int *)&__m128_op1[2]) = 0xffffffff;
+  *((int *)&__m128_op1[1]) = 0xffffc000;
+  *((int *)&__m128_op1[0]) = 0xffffc005;
+  *((int *)&__m128_op2[3]) = 0xff550025;
+  *((int *)&__m128_op2[2]) = 0x002a004b;
+  *((int *)&__m128_op2[1]) = 0x00590013;
+  *((int *)&__m128_op2[0]) = 0x005cffca;
+  *((int *)&__m128_result[3]) = 0xffffffff;
+  *((int *)&__m128_result[2]) = 0xffffffff;
+  *((int *)&__m128_result[1]) = 0xffffc000;
+  *((int *)&__m128_result[0]) = 0xffffc005;
+  __m128_out = __lsx_vfmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00000000;
+  *((int *)&__m128_op0[2]) = 0x00000000;
+  *((int *)&__m128_op0[1]) = 0x00000000;
+  *((int *)&__m128_op0[0]) = 0x00000000;
+  *((int *)&__m128_op1[3]) = 0x00fe0001;
+  *((int *)&__m128_op1[2]) = 0x00cf005f;
+  *((int *)&__m128_op1[1]) = 0x7fff7fff;
+  *((int *)&__m128_op1[0]) = 0x7fff7f00;
+  *((int *)&__m128_op2[3]) = 0x5d7f5d00;
+  *((int *)&__m128_op2[2]) = 0x7f6a007f;
+  *((int *)&__m128_op2[1]) = 0x00000000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0x5d7f5d00;
+  *((int *)&__m128_result[2]) = 0x7f6a007f;
+  *((int *)&__m128_result[1]) = 0x7fff7fff;
+  *((int *)&__m128_result[0]) = 0x7fff7f00;
+  __m128_out = __lsx_vfmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00680486;
+  *((int *)&__m128_op0[2]) = 0xffffffda;
+  *((int *)&__m128_op0[1]) = 0xffff913b;
+  *((int *)&__m128_op0[0]) = 0xb9951901;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x01030103;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x00200060;
+  *((int *)&__m128_op2[0]) = 0x00200060;
+  *((int *)&__m128_result[3]) = 0x00000000;
+  *((int *)&__m128_result[2]) = 0xffffffda;
+  *((int *)&__m128_result[1]) = 0xffff913b;
+  *((int *)&__m128_result[0]) = 0x001fed4d;
+  __m128_out = __lsx_vfmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x001a001a;
+  *((int *)&__m128_op0[2]) = 0x001a0008;
+  *((int *)&__m128_op0[1]) = 0x001a001a;
+  *((int *)&__m128_op0[0]) = 0x001a000b;
+  *((int *)&__m128_op1[3]) = 0xffffffff;
+  *((int *)&__m128_op1[2]) = 0xffffffff;
+  *((int *)&__m128_op1[1]) = 0xff800001;
+  *((int *)&__m128_op1[0]) = 0x0f800000;
+  *((int *)&__m128_op2[3]) = 0xff800000;
+  *((int *)&__m128_op2[2]) = 0xff800000;
+  *((int *)&__m128_op2[1]) = 0xff800000;
+  *((int *)&__m128_op2[0]) = 0xff800000;
+  *((int *)&__m128_result[3]) = 0xffffffff;
+  *((int *)&__m128_result[2]) = 0xffffffff;
+  *((int *)&__m128_result[1]) = 0xffc00001;
+  *((int *)&__m128_result[0]) = 0xff800000;
+  __m128_out = __lsx_vfmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0xfe3bfb01;
+  *((int *)&__m128_op0[2]) = 0xfe3bfe01;
+  *((int *)&__m128_op0[1]) = 0xfe03fe3f;
+  *((int *)&__m128_op0[0]) = 0xfe01fa21;
+  *((int *)&__m128_op1[3]) = 0xfe3bfb01;
+  *((int *)&__m128_op1[2]) = 0xfe3bfe01;
+  *((int *)&__m128_op1[1]) = 0xfe03fe3f;
+  *((int *)&__m128_op1[0]) = 0xfe01fa21;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x00000000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0x7f800000;
+  *((int *)&__m128_result[2]) = 0x7f800000;
+  *((int *)&__m128_result[1]) = 0x7f800000;
+  *((int *)&__m128_result[0]) = 0x7f800000;
+  __m128_out = __lsx_vfmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00000000;
+  *((int *)&__m128_op0[2]) = 0x00000000;
+  *((int *)&__m128_op0[1]) = 0x00000000;
+  *((int *)&__m128_op0[0]) = 0x00000000;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x00000000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0x00000000;
+  *((int *)&__m128_result[2]) = 0x00000000;
+  *((int *)&__m128_result[1]) = 0x00000000;
+  *((int *)&__m128_result[0]) = 0x00000000;
+  __m128_out = __lsx_vfmsub_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0xffffe001;
+  *((int *)&__m128_op0[2]) = 0xffffe001;
+  *((int *)&__m128_op0[1]) = 0xffffe001;
+  *((int *)&__m128_op0[0]) = 0xffffe001;
+  *((int *)&__m128_op1[3]) = 0xffffffff;
+  *((int *)&__m128_op1[2]) = 0xffffffff;
+  *((int *)&__m128_op1[1]) = 0xffffe000;
+  *((int *)&__m128_op1[0]) = 0x01ffe200;
+  *((int *)&__m128_op2[3]) = 0x04040383;
+  *((int *)&__m128_op2[2]) = 0x83838404;
+  *((int *)&__m128_op2[1]) = 0x04040383;
+  *((int *)&__m128_op2[0]) = 0x83838404;
+  *((int *)&__m128_result[3]) = 0xffffe001;
+  *((int *)&__m128_result[2]) = 0xffffe001;
+  *((int *)&__m128_result[1]) = 0xffffe001;
+  *((int *)&__m128_result[0]) = 0xffffe001;
+  __m128_out = __lsx_vfmsub_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x18171615;
+  *((int *)&__m128_op0[2]) = 0x17161514;
+  *((int *)&__m128_op0[1]) = 0x16151413;
+  *((int *)&__m128_op0[0]) = 0x151d3756;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x39412488;
+  *((int *)&__m128_op1[0]) = 0x80000000;
+  *((int *)&__m128_op2[3]) = 0x3ff00000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x40f3fa00;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0xbff00000;
+  *((int *)&__m128_result[2]) = 0x00000000;
+  *((int *)&__m128_result[1]) = 0xc0f3fa00;
+  *((int *)&__m128_result[0]) = 0x80000000;
+  __m128_out = __lsx_vfmsub_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00000000;
+  *((int *)&__m128_op0[2]) = 0x00000000;
+  *((int *)&__m128_op0[1]) = 0x00000000;
+  *((int *)&__m128_op0[0]) = 0x00000000;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x00000005;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x00000000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0x00000000;
+  *((int *)&__m128_result[2]) = 0x00000000;
+  *((int *)&__m128_result[1]) = 0x00000000;
+  *((int *)&__m128_result[0]) = 0x00000000;
+  __m128_out = __lsx_vfmsub_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00000000;
+  *((int *)&__m128_op0[2]) = 0x00000000;
+  *((int *)&__m128_op0[1]) = 0x00000000;
+  *((int *)&__m128_op0[0]) = 0x3ddc5dac;
+  *((int *)&__m128_op1[3]) = 0xffffffff;
+  *((int *)&__m128_op1[2]) = 0xffffffff;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x00000000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0xffffffff;
+  *((int *)&__m128_result[2]) = 0xffffffff;
+  *((int *)&__m128_result[1]) = 0x00000000;
+  *((int *)&__m128_result[0]) = 0x00000000;
+  __m128_out = __lsx_vfmsub_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x63636b6a;
+  *((int *)&__m128_op0[2]) = 0xfe486741;
+  *((int *)&__m128_op0[1]) = 0x41f8e880;
+  *((int *)&__m128_op0[0]) = 0xffffffff;
+  *((int *)&__m128_op1[3]) = 0xe3636363;
+  *((int *)&__m128_op1[2]) = 0x63abdf16;
+  *((int *)&__m128_op1[1]) = 0x41f8e080;
+  *((int *)&__m128_op1[0]) = 0x16161198;
+  *((int *)&__m128_op2[3]) = 0x00c27580;
+  *((int *)&__m128_op2[2]) = 0x00bccf42;
+  *((int *)&__m128_op2[1]) = 0x00a975be;
+  *((int *)&__m128_op2[0]) = 0x00accf03;
+  *((int *)&__m128_result[3]) = 0xff800000;
+  *((int *)&__m128_result[2]) = 0xff800000;
+  *((int *)&__m128_result[1]) = 0x4471fb84;
+  *((int *)&__m128_result[0]) = 0xffffffff;
+  __m128_out = __lsx_vfmsub_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vfnmadd_d.c b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vfnmadd_d.c
new file mode 100644
index 00000000000..96b14aad6c4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vfnmadd_d.c
@@ -0,0 +1,196 @@
+/* { dg-do run } */
+/* { dg-options "-mlsx -w -fno-strict-aliasing" } */
+#include "../simd_correctness_check.h"
+#include <lsxintrin.h>
+
+int
+main ()
+{
+  __m128i __m128i_op0, __m128i_op1, __m128i_op2, __m128i_out, __m128i_result;
+  __m128 __m128_op0, __m128_op1, __m128_op2, __m128_out, __m128_result;
+  __m128d __m128d_op0, __m128d_op1, __m128d_op2, __m128d_out, __m128d_result;
+
+  int int_op0, int_op1, int_op2, int_out, int_result, i = 1, fail;
+  long int long_op0, long_op1, long_op2, lont_out, lont_result;
+  long int long_int_out, long_int_result;
+  unsigned int unsigned_int_out, unsigned_int_result;
+  unsigned long int unsigned_long_int_out, unsigned_long_int_result;
+
+  *((unsigned long *)&__m128d_op0[1]) = 0xef0179a47c793879;
+  *((unsigned long *)&__m128d_op0[0]) = 0x9f9e7e3e9ea3ff41;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[1]) = 0x7fc000007fc00000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x1e801ffc7fc00000;
+  *((unsigned long *)&__m128d_result[1]) = 0xffc000007fc00000;
+  *((unsigned long *)&__m128d_result[0]) = 0x9e801ffc7fc00000;
+  __m128d_out = __lsx_vfnmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0x3f8000003f800000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000ffff00000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000ffff00000000;
+  *((unsigned long *)&__m128d_result[1]) = 0x8000ffff00000000;
+  *((unsigned long *)&__m128d_result[0]) = 0x8000ffff00000000;
+  __m128d_out = __lsx_vfnmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0xffffffbfffffffbf;
+  *((unsigned long *)&__m128d_op0[0]) = 0xffffffbfffffffbf;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000008800022;
+  *((unsigned long *)&__m128d_op1[0]) = 0xffffffff00000001;
+  *((unsigned long *)&__m128d_op2[1]) = 0xb8ec43befe38e64b;
+  *((unsigned long *)&__m128d_op2[0]) = 0x6477d042343cce24;
+  *((unsigned long *)&__m128d_result[1]) = 0xffffffbfffffffbf;
+  *((unsigned long *)&__m128d_result[0]) = 0xffffffbfffffffbf;
+  __m128d_out = __lsx_vfnmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0xfffffffffffff000;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0000000060000000;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[1]) = 0x8000000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0xfffffffffffff000;
+  __m128d_out = __lsx_vfnmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0xfffffffafffffffa;
+  *((unsigned long *)&__m128d_op0[0]) = 0xfffffffafffffffa;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[1]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_op2[0]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_result[1]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_result[0]) = 0xffffffffffffffff;
+  __m128d_out = __lsx_vfnmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0xf8f8f8f8f8f8f8f8;
+  *((unsigned long *)&__m128d_op1[0]) = 0xf8f8f8f8f8f8f8f8;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[1]) = 0x8000000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0x8000000000000000;
+  __m128d_out = __lsx_vfnmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[1]) = 0x8000000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0x8000000000000000;
+  __m128d_out = __lsx_vfnmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000008000000080;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0000008000000080;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[1]) = 0x8000000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0x8000000000000000;
+  __m128d_out = __lsx_vfnmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0xff80ffa2fff0ff74;
+  *((unsigned long *)&__m128d_op0[0]) = 0xff76ffd8ffe6ffaa;
+  *((unsigned long *)&__m128d_op1[1]) = 0xff80ffa2fff0ff74;
+  *((unsigned long *)&__m128d_op1[0]) = 0xff76ffd8ffe6ffaa;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0303030303030303;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0303030303030303;
+  *((unsigned long *)&__m128d_result[1]) = 0xfff0000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0xfff0000000000000;
+  __m128d_out = __lsx_vfnmadd_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0xffffffff00000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0xffffffff00000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[1]) = 0xffffffff00000000;
+  *((unsigned long *)&__m128d_result[0]) = 0x8000000000000000;
+  __m128d_out = __lsx_vfnmsub_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000ffff0000ffff;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0001ffff00000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0001ffff0001ffff;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[1]) = 0x8000000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0x8000000000000000;
+  __m128d_out = __lsx_vfnmsub_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000001;
+  *((unsigned long *)&__m128d_op0[0]) = 0xfffffffffffffffe;
+  *((unsigned long *)&__m128d_op1[1]) = 0xff800000ff800000;
+  *((unsigned long *)&__m128d_op1[0]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[1]) = 0x3c600000ff800000;
+  *((unsigned long *)&__m128d_result[0]) = 0xfffffffffffffffe;
+  __m128d_out = __lsx_vfnmsub_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x000000000000000d;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x000000000000000d;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x00000000b5207f80;
+  *((unsigned long *)&__m128d_result[1]) = 0x8000000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0x00000000b5207f80;
+  __m128d_out = __lsx_vfnmsub_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0xffffffffffffffff;
+  *((unsigned long *)&__m128d_result[1]) = 0x8000000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0xffffffffffffffff;
+  __m128d_out = __lsx_vfnmsub_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op0[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000009000900;
+  *((unsigned long *)&__m128d_op1[0]) = 0x0000000009000900;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_result[1]) = 0x8000000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0x8000000000000000;
+  __m128d_out = __lsx_vfnmsub_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  *((unsigned long *)&__m128d_op0[1]) = 0x00c2758000bccf42;
+  *((unsigned long *)&__m128d_op0[0]) = 0x00a975be00accf03;
+  *((unsigned long *)&__m128d_op1[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op1[0]) = 0x00000000ffffffff;
+  *((unsigned long *)&__m128d_op2[1]) = 0x0000000000000000;
+  *((unsigned long *)&__m128d_op2[0]) = 0x00000000ffffffff;
+  *((unsigned long *)&__m128d_result[1]) = 0x8000000000000000;
+  *((unsigned long *)&__m128d_result[0]) = 0x00000000ffffffff;
+  __m128d_out = __lsx_vfnmsub_d (__m128d_op0, __m128d_op1, __m128d_op2);
+  ASSERTEQ_64 (__LINE__, __m128d_result, __m128d_out);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vfnmadd_s.c b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vfnmadd_s.c
new file mode 100644
index 00000000000..bf8414b492c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vfnmadd_s.c
@@ -0,0 +1,381 @@
+/* { dg-do run } */
+/* { dg-options "-mlsx -w -fno-strict-aliasing" } */
+#include "../simd_correctness_check.h"
+#include <lsxintrin.h>
+
+int
+main ()
+{
+  __m128i __m128i_op0, __m128i_op1, __m128i_op2, __m128i_out, __m128i_result;
+  __m128 __m128_op0, __m128_op1, __m128_op2, __m128_out, __m128_result;
+  __m128d __m128d_op0, __m128d_op1, __m128d_op2, __m128d_out, __m128d_result;
+
+  int int_op0, int_op1, int_op2, int_out, int_result, i = 1, fail;
+  long int long_op0, long_op1, long_op2, lont_out, lont_result;
+  long int long_int_out, long_int_result;
+  unsigned int unsigned_int_out, unsigned_int_result;
+  unsigned long int unsigned_long_int_out, unsigned_long_int_result;
+
+  *((int *)&__m128_op0[3]) = 0xffffffff;
+  *((int *)&__m128_op0[2]) = 0xffffffff;
+  *((int *)&__m128_op0[1]) = 0xfffffffe;
+  *((int *)&__m128_op0[0]) = 0xbe6ed565;
+  *((int *)&__m128_op1[3]) = 0x195f307a;
+  *((int *)&__m128_op1[2]) = 0x5d04acbb;
+  *((int *)&__m128_op1[1]) = 0x6a1a3fbb;
+  *((int *)&__m128_op1[0]) = 0x3c90260e;
+  *((int *)&__m128_op2[3]) = 0xffffffff;
+  *((int *)&__m128_op2[2]) = 0xffffffff;
+  *((int *)&__m128_op2[1]) = 0xfffffffe;
+  *((int *)&__m128_op2[0]) = 0xbe6ed565;
+  *((int *)&__m128_result[3]) = 0xffffffff;
+  *((int *)&__m128_result[2]) = 0xffffffff;
+  *((int *)&__m128_result[1]) = 0xfffffffe;
+  *((int *)&__m128_result[0]) = 0x3e730941;
+  __m128_out = __lsx_vfnmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0xffffffff;
+  *((int *)&__m128_op0[2]) = 0xffffffff;
+  *((int *)&__m128_op0[1]) = 0xffffffff;
+  *((int *)&__m128_op0[0]) = 0xff01ff01;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0xffffffff;
+  *((int *)&__m128_op2[2]) = 0xffffffff;
+  *((int *)&__m128_op2[1]) = 0xffffffff;
+  *((int *)&__m128_op2[0]) = 0xff01ff01;
+  *((int *)&__m128_result[3]) = 0xffffffff;
+  *((int *)&__m128_result[2]) = 0xffffffff;
+  *((int *)&__m128_result[1]) = 0xffffffff;
+  *((int *)&__m128_result[0]) = 0x7f01ff01;
+  __m128_out = __lsx_vfnmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00000000;
+  *((int *)&__m128_op0[2]) = 0x00000000;
+  *((int *)&__m128_op0[1]) = 0x00000000;
+  *((int *)&__m128_op0[0]) = 0x00000000;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0xffffffff;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0xffffffff;
+  *((int *)&__m128_op2[3]) = 0x00307028;
+  *((int *)&__m128_op2[2]) = 0x003f80b0;
+  *((int *)&__m128_op2[1]) = 0x0040007f;
+  *((int *)&__m128_op2[0]) = 0xff800000;
+  *((int *)&__m128_result[3]) = 0x80307028;
+  *((int *)&__m128_result[2]) = 0xffffffff;
+  *((int *)&__m128_result[1]) = 0x8040007f;
+  *((int *)&__m128_result[0]) = 0xffffffff;
+  __m128_out = __lsx_vfnmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00000049;
+  *((int *)&__m128_op0[2]) = 0x0000004d;
+  *((int *)&__m128_op0[1]) = 0x00000001;
+  *((int *)&__m128_op0[0]) = 0xffffffff;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x00000001;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x00000001;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0x80000000;
+  *((int *)&__m128_result[2]) = 0x80000000;
+  *((int *)&__m128_result[1]) = 0x80000001;
+  *((int *)&__m128_result[0]) = 0xffffffff;
+  __m128_out = __lsx_vfnmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0xffffffff;
+  *((int *)&__m128_op0[2]) = 0xffff0000;
+  *((int *)&__m128_op0[1]) = 0x00ff0000;
+  *((int *)&__m128_op0[0]) = 0x00ff0000;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000800;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0xffffffff;
+  *((int *)&__m128_op2[2]) = 0xfffff800;
+  *((int *)&__m128_op2[1]) = 0x00000000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0xffffffff;
+  *((int *)&__m128_result[2]) = 0xfffff800;
+  *((int *)&__m128_result[1]) = 0x80000000;
+  *((int *)&__m128_result[0]) = 0x80000000;
+  __m128_out = __lsx_vfnmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00000000;
+  *((int *)&__m128_op0[2]) = 0x00000000;
+  *((int *)&__m128_op0[1]) = 0x00000000;
+  *((int *)&__m128_op0[0]) = 0x00000000;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x00000000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0x80000000;
+  *((int *)&__m128_result[2]) = 0x80000000;
+  *((int *)&__m128_result[1]) = 0x80000000;
+  *((int *)&__m128_result[0]) = 0x80000000;
+  __m128_out = __lsx_vfnmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00030000;
+  *((int *)&__m128_op0[2]) = 0x00010000;
+  *((int *)&__m128_op0[1]) = 0x00020000;
+  *((int *)&__m128_op0[0]) = 0x00010000;
+  *((int *)&__m128_op1[3]) = 0x3f800000;
+  *((int *)&__m128_op1[2]) = 0x3f800000;
+  *((int *)&__m128_op1[1]) = 0x3f800000;
+  *((int *)&__m128_op1[0]) = 0x3f800000;
+  *((int *)&__m128_op2[3]) = 0x00030000;
+  *((int *)&__m128_op2[2]) = 0x00010000;
+  *((int *)&__m128_op2[1]) = 0x00020000;
+  *((int *)&__m128_op2[0]) = 0x00010000;
+  *((int *)&__m128_result[3]) = 0x80060000;
+  *((int *)&__m128_result[2]) = 0x80020000;
+  *((int *)&__m128_result[1]) = 0x80040000;
+  *((int *)&__m128_result[0]) = 0x80020000;
+  __m128_out = __lsx_vfnmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00000008;
+  *((int *)&__m128_op0[2]) = 0x97957687;
+  *((int *)&__m128_op0[1]) = 0x00000000;
+  *((int *)&__m128_op0[0]) = 0x00000408;
+  *((int *)&__m128_op1[3]) = 0x00000008;
+  *((int *)&__m128_op1[2]) = 0x97957687;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x00000408;
+  *((int *)&__m128_op2[3]) = 0x00010001;
+  *((int *)&__m128_op2[2]) = 0x00010001;
+  *((int *)&__m128_op2[1]) = 0x00010001;
+  *((int *)&__m128_op2[0]) = 0x04000800;
+  *((int *)&__m128_result[3]) = 0x80010001;
+  *((int *)&__m128_result[2]) = 0x80010001;
+  *((int *)&__m128_result[1]) = 0x80010001;
+  *((int *)&__m128_result[0]) = 0x84000800;
+  __m128_out = __lsx_vfnmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0xffc2ffe7;
+  *((int *)&__m128_op0[2]) = 0x00000007;
+  *((int *)&__m128_op0[1]) = 0x0000ffc1;
+  *((int *)&__m128_op0[0]) = 0x00010001;
+  *((int *)&__m128_op1[3]) = 0xffc2ffe7;
+  *((int *)&__m128_op1[2]) = 0x00000007;
+  *((int *)&__m128_op1[1]) = 0x0000ffc1;
+  *((int *)&__m128_op1[0]) = 0x00010001;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x000ffc2f;
+  *((int *)&__m128_op2[1]) = 0x00201df0;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0xffc2ffe7;
+  *((int *)&__m128_result[2]) = 0x800ffc2f;
+  *((int *)&__m128_result[1]) = 0x80201df0;
+  *((int *)&__m128_result[0]) = 0x80000000;
+  __m128_out = __lsx_vfnmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00000000;
+  *((int *)&__m128_op0[2]) = 0x00000000;
+  *((int *)&__m128_op0[1]) = 0x00000000;
+  *((int *)&__m128_op0[0]) = 0x00000000;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x00000000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0x80000000;
+  *((int *)&__m128_result[2]) = 0x80000000;
+  *((int *)&__m128_result[1]) = 0x80000000;
+  *((int *)&__m128_result[0]) = 0x80000000;
+  __m128_out = __lsx_vfnmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00000000;
+  *((int *)&__m128_op0[2]) = 0x00000000;
+  *((int *)&__m128_op0[1]) = 0x00000000;
+  *((int *)&__m128_op0[0]) = 0x00000005;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x00000000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0x80000000;
+  *((int *)&__m128_result[2]) = 0x80000000;
+  *((int *)&__m128_result[1]) = 0x80000000;
+  *((int *)&__m128_result[0]) = 0x80000000;
+  __m128_out = __lsx_vfnmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x80808080;
+  *((int *)&__m128_op0[2]) = 0x80808080;
+  *((int *)&__m128_op0[1]) = 0x80808080;
+  *((int *)&__m128_op0[0]) = 0x80800008;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x00000000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0x80000000;
+  *((int *)&__m128_result[2]) = 0x80000000;
+  *((int *)&__m128_result[1]) = 0x80000000;
+  *((int *)&__m128_result[0]) = 0x80000000;
+  __m128_out = __lsx_vfnmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00000000;
+  *((int *)&__m128_op0[2]) = 0x00000000;
+  *((int *)&__m128_op0[1]) = 0x31313131;
+  *((int *)&__m128_op0[0]) = 0x31313131;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x31313131;
+  *((int *)&__m128_op1[0]) = 0x31313131;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000008;
+  *((int *)&__m128_op2[1]) = 0x00000000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0x80000000;
+  *((int *)&__m128_result[2]) = 0x80000008;
+  *((int *)&__m128_result[1]) = 0xa2f54a1e;
+  *((int *)&__m128_result[0]) = 0xa2f54a1e;
+  __m128_out = __lsx_vfnmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00000000;
+  *((int *)&__m128_op0[2]) = 0x00000000;
+  *((int *)&__m128_op0[1]) = 0x00000000;
+  *((int *)&__m128_op0[0]) = 0x00000000;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x00000000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0x80000000;
+  *((int *)&__m128_result[2]) = 0x80000000;
+  *((int *)&__m128_result[1]) = 0x80000000;
+  *((int *)&__m128_result[0]) = 0x80000000;
+  __m128_out = __lsx_vfnmadd_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0xa486c90f;
+  *((int *)&__m128_op0[2]) = 0x157ca12e;
+  *((int *)&__m128_op0[1]) = 0x58bcc201;
+  *((int *)&__m128_op0[0]) = 0x2e635d65;
+  *((int *)&__m128_op1[3]) = 0x6d564875;
+  *((int *)&__m128_op1[2]) = 0xf8760005;
+  *((int *)&__m128_op1[1]) = 0x8dc5a4d1;
+  *((int *)&__m128_op1[0]) = 0x79ffa22f;
+  *((int *)&__m128_op2[3]) = 0xffffffff;
+  *((int *)&__m128_op2[2]) = 0xd2436487;
+  *((int *)&__m128_op2[1]) = 0x0fa96b88;
+  *((int *)&__m128_op2[0]) = 0x5f94ab13;
+  *((int *)&__m128_result[3]) = 0xffffffff;
+  *((int *)&__m128_result[2]) = 0xd24271c4;
+  *((int *)&__m128_result[1]) = 0x2711bad1;
+  *((int *)&__m128_result[0]) = 0xe8e309ed;
+  __m128_out = __lsx_vfnmsub_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00000000;
+  *((int *)&__m128_op0[2]) = 0x00000000;
+  *((int *)&__m128_op0[1]) = 0x00000000;
+  *((int *)&__m128_op0[0]) = 0x00000000;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x00000000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0x80000000;
+  *((int *)&__m128_result[2]) = 0x80000000;
+  *((int *)&__m128_result[1]) = 0x80000000;
+  *((int *)&__m128_result[0]) = 0x80000000;
+  __m128_out = __lsx_vfnmsub_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00000000;
+  *((int *)&__m128_op0[2]) = 0x00000000;
+  *((int *)&__m128_op0[1]) = 0x00000000;
+  *((int *)&__m128_op0[0]) = 0x00000000;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x007ffd00;
+  *((int *)&__m128_op2[0]) = 0x01400840;
+  *((int *)&__m128_result[3]) = 0x80000000;
+  *((int *)&__m128_result[2]) = 0x80000000;
+  *((int *)&__m128_result[1]) = 0x007ffd00;
+  *((int *)&__m128_result[0]) = 0x01400840;
+  __m128_out = __lsx_vfnmsub_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00000000;
+  *((int *)&__m128_op0[2]) = 0x00000000;
+  *((int *)&__m128_op0[1]) = 0x00000000;
+  *((int *)&__m128_op0[0]) = 0x00000000;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0x00000000;
+  *((int *)&__m128_op2[2]) = 0x00000000;
+  *((int *)&__m128_op2[1]) = 0x7f800000;
+  *((int *)&__m128_op2[0]) = 0x00000000;
+  *((int *)&__m128_result[3]) = 0x80000000;
+  *((int *)&__m128_result[2]) = 0x80000000;
+  *((int *)&__m128_result[1]) = 0x7f800000;
+  *((int *)&__m128_result[0]) = 0x80000000;
+  __m128_out = __lsx_vfnmsub_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  *((int *)&__m128_op0[3]) = 0x00000000;
+  *((int *)&__m128_op0[2]) = 0x00000000;
+  *((int *)&__m128_op0[1]) = 0x00000000;
+  *((int *)&__m128_op0[0]) = 0x00000000;
+  *((int *)&__m128_op1[3]) = 0x00000000;
+  *((int *)&__m128_op1[2]) = 0x00000000;
+  *((int *)&__m128_op1[1]) = 0x00000000;
+  *((int *)&__m128_op1[0]) = 0x00000000;
+  *((int *)&__m128_op2[3]) = 0xcd636363;
+  *((int *)&__m128_op2[2]) = 0xcd636363;
+  *((int *)&__m128_op2[1]) = 0xcd636363;
+  *((int *)&__m128_op2[0]) = 0xcd636363;
+  *((int *)&__m128_result[3]) = 0xcd636363;
+  *((int *)&__m128_result[2]) = 0xcd636363;
+  *((int *)&__m128_result[1]) = 0xcd636363;
+  *((int *)&__m128_result[0]) = 0xcd636363;
+  __m128_out = __lsx_vfnmsub_s (__m128_op0, __m128_op1, __m128_op2);
+  ASSERTEQ_32 (__LINE__, __m128_result, __m128_out);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vld.c b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vld.c
new file mode 100644
index 00000000000..7cd9abb7c69
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vld.c
@@ -0,0 +1,62 @@
+/* { dg-do run } */
+/* { dg-options "-mlsx -w -fno-strict-aliasing" } */
+#include "../simd_correctness_check.h"
+#include <lsxintrin.h>
+
+int
+main ()
+{
+  __m128i __m128i_op0, __m128i_op1, __m128i_op2, __m128i_out, __m128i_result;
+  __m128 __m128_op0, __m128_op1, __m128_op2, __m128_out, __m128_result;
+  __m128d __m128d_op0, __m128d_op1, __m128d_op2, __m128d_out, __m128d_result;
+
+  int int_op0, int_op1, int_op2, int_out, int_result, i = 1, fail;
+  long int long_op0, long_op1, long_op2, lont_out, lont_result;
+  long int long_int_out, long_int_result;
+  unsigned int unsigned_int_out, unsigned_int_result;
+  unsigned long int unsigned_long_int_out, unsigned_long_int_result;
+
+  *((unsigned long *)&__m128i_op0[1]) = 0x1dcc4255c9d85c05;
+  *((unsigned long *)&__m128i_op0[0]) = 0x3ab7a3fc47a5c31a;
+  *((unsigned long *)&__m128i_result[1]) = 0x1dcc4255c9d85c05;
+  *((unsigned long *)&__m128i_result[0]) = 0x3ab7a3fc47a5c31a;
+  __m128i_out = __lsx_vld ((unsigned long *)&__m128i_op0, 0x0);
+  ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+  *((unsigned long *)&__m128i_op0[1]) = 0x1dcc4255c9d85c05;
+  *((unsigned long *)&__m128i_op0[0]) = 0x3ab7a3fc47a5c31a;
+  *((unsigned long *)&__m128i_result[1]) = 0x1dcc4255c9d85c05;
+  *((unsigned long *)&__m128i_result[0]) = 0x3ab7a3fc47a5c31a;
+  __m128i_out = __lsx_vldx ((unsigned long *)&__m128i_op0, 0x0);
+  ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+  *((unsigned long *)&__m128i_op0[1]) = 0x1dcc4255c9d85c05;
+  *((unsigned long *)&__m128i_op0[0]) = 0x3ab7a3fc47a5c31a;
+  *((unsigned long *)&__m128i_result[1]) = 0xc3c3c3c3c3c3c3c3;
+  *((unsigned long *)&__m128i_result[0]) = 0xc3c3c3c3c3c3c3c3;
+  __m128i_out = __lsx_vldrepl_b ((unsigned long *)&__m128i_op0, 0x1);
+  ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+  *((unsigned long *)&__m128i_op0[1]) = 0x1dcc4255c9d85c05;
+  *((unsigned long *)&__m128i_op0[0]) = 0x3ab7a3fc47a5c31a;
+  *((unsigned long *)&__m128i_result[1]) = 0xc31ac31ac31ac31a;
+  *((unsigned long *)&__m128i_result[0]) = 0xc31ac31ac31ac31a;
+  __m128i_out = __lsx_vldrepl_h ((unsigned long *)&__m128i_op0, 0x0);
+  ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+  *((unsigned long *)&__m128i_op0[1]) = 0x1dcc4255c9d85c05;
+  *((unsigned long *)&__m128i_op0[0]) = 0x3ab7a3fc47a5c31a;
+  *((unsigned long *)&__m128i_result[1]) = 0x47a5c31a47a5c31a;
+  *((unsigned long *)&__m128i_result[0]) = 0x47a5c31a47a5c31a;
+  __m128i_out = __lsx_vldrepl_w ((unsigned long *)&__m128i_op0, 0x0);
+  ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+  *((unsigned long *)&__m128i_op0[1]) = 0x1dcc4255c9d85c05;
+  *((unsigned long *)&__m128i_op0[0]) = 0x3ab7a3fc47a5c31a;
+  *((unsigned long *)&__m128i_result[1]) = 0x3ab7a3fc47a5c31a;
+  *((unsigned long *)&__m128i_result[0]) = 0x3ab7a3fc47a5c31a;
+  __m128i_out = __lsx_vldrepl_d ((unsigned long *)&__m128i_op0, 0x0);
+  ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vst.c b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vst.c
new file mode 100644
index 00000000000..8afdffa508a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-vst.c
@@ -0,0 +1,70 @@
+/* { dg-do run } */
+/* { dg-options "-mlsx -w -fno-strict-aliasing" } */
+#include "../simd_correctness_check.h"
+#include <lsxintrin.h>
+
+int
+main ()
+{
+  __m128i __m128i_op0, __m128i_op1, __m128i_op2, __m128i_out, __m128i_result;
+  __m128 __m128_op0, __m128_op1, __m128_op2, __m128_out, __m128_result;
+  __m128d __m128d_op0, __m128d_op1, __m128d_op2, __m128d_out, __m128d_result;
+
+  int int_op0, int_op1, int_op2, int_out, int_result, i = 1, fail;
+  long int long_op0, long_op1, long_op2, lont_out, lont_result;
+  long int long_int_out, long_int_result;
+  unsigned int unsigned_int_out, unsigned_int_result;
+  unsigned long int unsigned_long_int_out, unsigned_long_int_result;
+
+  *((unsigned long *)&__m128i_op0[1]) = 0x1dcc4255c9d85c05;
+  *((unsigned long *)&__m128i_op0[0]) = 0x3ab7a3fc47a5c31a;
+  *((unsigned long *)&__m128i_result[1]) = 0x0;
+  *((unsigned long *)&__m128i_result[0]) = 0x0;
+  __lsx_vst (__m128i_op0, (unsigned long *)&__m128i_result, 0x0);
+  ASSERTEQ_64 (__LINE__, __m128i_op0, __m128i_result);
+
+  *((unsigned long *)&__m128i_op0[1]) = 0x1dcc4255c9d85c05;
+  *((unsigned long *)&__m128i_op0[0]) = 0x3ab7a3fc47a5c31a;
+  *((unsigned long *)&__m128i_result[1]) = 0x0;
+  *((unsigned long *)&__m128i_result[0]) = 0x0;
+  __lsx_vstx (__m128i_op0, (unsigned long *)&__m128i_result, 0x0);
+  ASSERTEQ_64 (__LINE__, __m128i_op0, __m128i_result);
+
+  *((unsigned long *)&__m128i_op0[1]) = 0x1dcc4255c9d85c05;
+  *((unsigned long *)&__m128i_op0[0]) = 0x3ab7a3fc47a5c31a;
+  *((unsigned long *)&__m128i_result[1]) = 0x0;
+  *((unsigned long *)&__m128i_result[0]) = 0x05;
+  *((unsigned long *)&__m128i_out[1]) = 0x0;
+  *((unsigned long *)&__m128i_out[0]) = 0x0;
+  __lsx_vstelm_b (__m128i_op0, (unsigned long *)&__m128i_out, 0x0, 0x8);
+  ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+  *((unsigned long *)&__m128i_op0[1]) = 0x1dcc4255c9d85c05;
+  *((unsigned long *)&__m128i_op0[0]) = 0x3ab7a3fc47a5c31a;
+  *((unsigned long *)&__m128i_result[1]) = 0x0;
+  *((unsigned long *)&__m128i_result[0]) = 0x5c05;
+  *((unsigned long *)&__m128i_out[1]) = 0x0;
+  *((unsigned long *)&__m128i_out[0]) = 0x0;
+  __lsx_vstelm_h (__m128i_op0, (unsigned long *)&__m128i_out, 0x0, 0x4);
+  ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+  *((unsigned long *)&__m128i_op0[1]) = 0x1dcc4255c9d85c05;
+  *((unsigned long *)&__m128i_op0[0]) = 0x3ab7a3fc47a5c31a;
+  *((unsigned long *)&__m128i_result[1]) = 0x0;
+  *((unsigned long *)&__m128i_result[0]) = 0xc9d85c05;
+  *((unsigned long *)&__m128i_out[1]) = 0x0;
+  *((unsigned long *)&__m128i_out[0]) = 0x0;
+  __lsx_vstelm_w (__m128i_op0, (unsigned long *)&__m128i_out, 0x0, 0x2);
+  ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+  *((unsigned long *)&__m128i_op0[1]) = 0x1dcc4255c9d85c05;
+  *((unsigned long *)&__m128i_op0[0]) = 0x3ab7a3fc47a5c31a;
+  *((unsigned long *)&__m128i_result[1]) = 0x0;
+  *((unsigned long *)&__m128i_result[0]) = 0x1dcc4255c9d85c05;
+  *((unsigned long *)&__m128i_out[1]) = 0x0;
+  *((unsigned long *)&__m128i_out[0]) = 0x0;
+  __lsx_vstelm_d (__m128i_op0, (unsigned long *)&__m128i_out, 0x0, 0x1);
+  ASSERTEQ_64 (__LINE__, __m128i_result, __m128i_out);
+
+  return 0;
+}
