diff --git a/gas/NEWS b/gas/NEWS
index 42bda657f21..26e75bde391 100644
--- a/gas/NEWS
+++ b/gas/NEWS
@@ -1,5 +1,7 @@
 -*- text -*-
 
+* Add support for Intel SM4 instructions.
+
 * Add support for Intel SM3 instructions.
 
 * Add support for Intel SHA512 instructions.
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 7424fa41c44..686dd4c70f4 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -1154,6 +1154,7 @@ static const arch_entry cpu_arch[] =
   SUBARCH (avx_vnni_int16, AVX_VNNI_INT16, ANY_AVX_VNNI_INT16, false),
   SUBARCH (sha512, SHA512, ANY_SHA512, false),
   SUBARCH (sm3, SM3, ANY_SM3, false),
+  SUBARCH (sm4, SM4, ANY_SM4, false),
 };
 
 #undef SUBARCH
diff --git a/gas/doc/c-i386.texi b/gas/doc/c-i386.texi
index 6ef1da21370..54b0d7d738c 100644
--- a/gas/doc/c-i386.texi
+++ b/gas/doc/c-i386.texi
@@ -210,6 +210,7 @@ accept various extension mnemonics.  For example,
 @code{avx_vnni_int16},
 @code{sha512},
 @code{sm3},
+@code{sm4},
 @code{amx_int8},
 @code{amx_bf16},
 @code{amx_fp16},
@@ -1639,7 +1640,7 @@ supported on the CPU specified.  The choices for @var{cpu_type} are:
 @item @samp{.prefetchi} @tab @samp{.avx_ifma} @tab @samp{.avx_vnni_int8}
 @item @samp{.cmpccxadd} @tab @samp{.wrmsrns} @tab @samp{.msrlist}
 @item @samp{.avx_ne_convert} @tab @samp{.rao_int} @tab @samp{.fred} @tab @samp{.lkgs}
-@item @samp{.avx_vnni_int16} @tab @samp{.sha512} @tab @samp{.sm3}
+@item @samp{.avx_vnni_int16} @tab @samp{.sha512} @tab @samp{.sm3} @tab @samp{.sm4}
 @item @samp{.wbnoinvd} @tab @samp{.pconfig} @tab @samp{.waitpkg} @tab @samp{.cldemote}
 @item @samp{.shstk} @tab @samp{.gfni} @tab @samp{.vaes} @tab @samp{.vpclmulqdq}
 @item @samp{.movdiri} @tab @samp{.movdir64b} @tab @samp{.enqcmd} @tab @samp{.tsxldtrk}
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index 2fcd3be1f98..e862d413c7e 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -503,6 +503,8 @@ if [gas_32_check] then {
     run_list_test "sha512-inval"
     run_dump_test "sm3"
     run_dump_test "sm3-intel"
+    run_dump_test "sm4"
+    run_dump_test "sm4-intel"
     run_list_test "sg"
     run_dump_test "clzero"
     run_dump_test "invlpgb"
diff --git a/gas/testsuite/gas/i386/sm4-intel.d b/gas/testsuite/gas/i386/sm4-intel.d
new file mode 100644
index 00000000000..03ccdb4a67b
--- /dev/null
+++ b/gas/testsuite/gas/i386/sm4-intel.d
@@ -0,0 +1,50 @@
+#as:
+#objdump: -dw -Mintel
+#name: i386 SM4 insns (Intel disassembly)
+#source: sm4.s
+
+.*: +file format .*
+
+Disassembly of section \.text:
+
+0+ <_start>:
+\s*[a-f0-9]+:\s*c4 e2 56 da f4\s+vsm4key4 ymm6,ymm5,ymm4
+\s*[a-f0-9]+:\s*c4 e2 52 da f4\s+vsm4key4 xmm6,xmm5,xmm4
+\s*[a-f0-9]+:\s*c4 e2 56 da b4 f4 00 00 00 10\s+vsm4key4 ymm6,ymm5,YMMWORD PTR \[esp\+esi\*8\+0x10000000\]
+\s*[a-f0-9]+:\s*c4 e2 56 da 31\s+vsm4key4 ymm6,ymm5,YMMWORD PTR \[ecx\]
+\s*[a-f0-9]+:\s*c4 e2 56 da b1 e0 0f 00 00\s+vsm4key4 ymm6,ymm5,YMMWORD PTR \[ecx\+0xfe0\]
+\s*[a-f0-9]+:\s*c4 e2 56 da b2 00 f0 ff ff\s+vsm4key4 ymm6,ymm5,YMMWORD PTR \[edx-0x1000\]
+\s*[a-f0-9]+:\s*c4 e2 52 da b4 f4 00 00 00 10\s+vsm4key4 xmm6,xmm5,XMMWORD PTR \[esp\+esi\*8\+0x10000000\]
+\s*[a-f0-9]+:\s*c4 e2 52 da 31\s+vsm4key4 xmm6,xmm5,XMMWORD PTR \[ecx\]
+\s*[a-f0-9]+:\s*c4 e2 52 da b1 f0 07 00 00\s+vsm4key4 xmm6,xmm5,XMMWORD PTR \[ecx\+0x7f0\]
+\s*[a-f0-9]+:\s*c4 e2 52 da b2 00 f8 ff ff\s+vsm4key4 xmm6,xmm5,XMMWORD PTR \[edx-0x800\]
+\s*[a-f0-9]+:\s*c4 e2 57 da f4\s+vsm4rnds4 ymm6,ymm5,ymm4
+\s*[a-f0-9]+:\s*c4 e2 53 da f4\s+vsm4rnds4 xmm6,xmm5,xmm4
+\s*[a-f0-9]+:\s*c4 e2 57 da b4 f4 00 00 00 10\s+vsm4rnds4 ymm6,ymm5,YMMWORD PTR \[esp\+esi\*8\+0x10000000\]
+\s*[a-f0-9]+:\s*c4 e2 57 da 31\s+vsm4rnds4 ymm6,ymm5,YMMWORD PTR \[ecx\]
+\s*[a-f0-9]+:\s*c4 e2 57 da b1 e0 0f 00 00\s+vsm4rnds4 ymm6,ymm5,YMMWORD PTR \[ecx\+0xfe0\]
+\s*[a-f0-9]+:\s*c4 e2 57 da b2 00 f0 ff ff\s+vsm4rnds4 ymm6,ymm5,YMMWORD PTR \[edx-0x1000\]
+\s*[a-f0-9]+:\s*c4 e2 53 da b4 f4 00 00 00 10\s+vsm4rnds4 xmm6,xmm5,XMMWORD PTR \[esp\+esi\*8\+0x10000000\]
+\s*[a-f0-9]+:\s*c4 e2 53 da 31\s+vsm4rnds4 xmm6,xmm5,XMMWORD PTR \[ecx\]
+\s*[a-f0-9]+:\s*c4 e2 53 da b1 f0 07 00 00\s+vsm4rnds4 xmm6,xmm5,XMMWORD PTR \[ecx\+0x7f0\]
+\s*[a-f0-9]+:\s*c4 e2 53 da b2 00 f8 ff ff\s+vsm4rnds4 xmm6,xmm5,XMMWORD PTR \[edx-0x800\]
+\s*[a-f0-9]+:\s*c4 e2 56 da f4\s+vsm4key4 ymm6,ymm5,ymm4
+\s*[a-f0-9]+:\s*c4 e2 52 da f4\s+vsm4key4 xmm6,xmm5,xmm4
+\s*[a-f0-9]+:\s*c4 e2 56 da b4 f4 00 00 00 10\s+vsm4key4 ymm6,ymm5,YMMWORD PTR \[esp\+esi\*8\+0x10000000\]
+\s*[a-f0-9]+:\s*c4 e2 56 da 31\s+vsm4key4 ymm6,ymm5,YMMWORD PTR \[ecx\]
+\s*[a-f0-9]+:\s*c4 e2 56 da b1 e0 0f 00 00\s+vsm4key4 ymm6,ymm5,YMMWORD PTR \[ecx\+0xfe0\]
+\s*[a-f0-9]+:\s*c4 e2 56 da b2 00 f0 ff ff\s+vsm4key4 ymm6,ymm5,YMMWORD PTR \[edx-0x1000\]
+\s*[a-f0-9]+:\s*c4 e2 52 da b4 f4 00 00 00 10\s+vsm4key4 xmm6,xmm5,XMMWORD PTR \[esp\+esi\*8\+0x10000000\]
+\s*[a-f0-9]+:\s*c4 e2 52 da 31\s+vsm4key4 xmm6,xmm5,XMMWORD PTR \[ecx\]
+\s*[a-f0-9]+:\s*c4 e2 52 da b1 f0 07 00 00\s+vsm4key4 xmm6,xmm5,XMMWORD PTR \[ecx\+0x7f0\]
+\s*[a-f0-9]+:\s*c4 e2 52 da b2 00 f8 ff ff\s+vsm4key4 xmm6,xmm5,XMMWORD PTR \[edx-0x800\]
+\s*[a-f0-9]+:\s*c4 e2 57 da f4\s+vsm4rnds4 ymm6,ymm5,ymm4
+\s*[a-f0-9]+:\s*c4 e2 53 da f4\s+vsm4rnds4 xmm6,xmm5,xmm4
+\s*[a-f0-9]+:\s*c4 e2 57 da b4 f4 00 00 00 10\s+vsm4rnds4 ymm6,ymm5,YMMWORD PTR \[esp\+esi\*8\+0x10000000\]
+\s*[a-f0-9]+:\s*c4 e2 57 da 31\s+vsm4rnds4 ymm6,ymm5,YMMWORD PTR \[ecx\]
+\s*[a-f0-9]+:\s*c4 e2 57 da b1 e0 0f 00 00\s+vsm4rnds4 ymm6,ymm5,YMMWORD PTR \[ecx\+0xfe0\]
+\s*[a-f0-9]+:\s*c4 e2 57 da b2 00 f0 ff ff\s+vsm4rnds4 ymm6,ymm5,YMMWORD PTR \[edx-0x1000\]
+\s*[a-f0-9]+:\s*c4 e2 53 da b4 f4 00 00 00 10\s+vsm4rnds4 xmm6,xmm5,XMMWORD PTR \[esp\+esi\*8\+0x10000000\]
+\s*[a-f0-9]+:\s*c4 e2 53 da 31\s+vsm4rnds4 xmm6,xmm5,XMMWORD PTR \[ecx\]
+\s*[a-f0-9]+:\s*c4 e2 53 da b1 f0 07 00 00\s+vsm4rnds4 xmm6,xmm5,XMMWORD PTR \[ecx\+0x7f0\]
+\s*[a-f0-9]+:\s*c4 e2 53 da b2 00 f8 ff ff\s+vsm4rnds4 xmm6,xmm5,XMMWORD PTR \[edx-0x800\]
diff --git a/gas/testsuite/gas/i386/sm4.d b/gas/testsuite/gas/i386/sm4.d
new file mode 100644
index 00000000000..48dcda66271
--- /dev/null
+++ b/gas/testsuite/gas/i386/sm4.d
@@ -0,0 +1,50 @@
+#as:
+#objdump: -dw
+#name: i386 SM4 insns
+#source: sm4.s
+
+.*: +file format .*
+
+Disassembly of section \.text:
+
+0+ <_start>:
+\s*[a-f0-9]+:\s*c4 e2 56 da f4\s+vsm4key4 %ymm4,%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 52 da f4\s+vsm4key4 %xmm4,%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 56 da b4 f4 00 00 00 10\s+vsm4key4 0x10000000\(%esp,%esi,8\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 56 da 31\s+vsm4key4 \(%ecx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 56 da b1 e0 0f 00 00\s+vsm4key4 0xfe0\(%ecx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 56 da b2 00 f0 ff ff\s+vsm4key4 -0x1000\(%edx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 52 da b4 f4 00 00 00 10\s+vsm4key4 0x10000000\(%esp,%esi,8\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 52 da 31\s+vsm4key4 \(%ecx\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 52 da b1 f0 07 00 00\s+vsm4key4 0x7f0\(%ecx\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 52 da b2 00 f8 ff ff\s+vsm4key4 -0x800\(%edx\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 57 da f4\s+vsm4rnds4 %ymm4,%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 53 da f4\s+vsm4rnds4 %xmm4,%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 57 da b4 f4 00 00 00 10\s+vsm4rnds4 0x10000000\(%esp,%esi,8\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 57 da 31\s+vsm4rnds4 \(%ecx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 57 da b1 e0 0f 00 00\s+vsm4rnds4 0xfe0\(%ecx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 57 da b2 00 f0 ff ff\s+vsm4rnds4 -0x1000\(%edx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 53 da b4 f4 00 00 00 10\s+vsm4rnds4 0x10000000\(%esp,%esi,8\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 53 da 31\s+vsm4rnds4 \(%ecx\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 53 da b1 f0 07 00 00\s+vsm4rnds4 0x7f0\(%ecx\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 53 da b2 00 f8 ff ff\s+vsm4rnds4 -0x800\(%edx\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 56 da f4\s+vsm4key4 %ymm4,%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 52 da f4\s+vsm4key4 %xmm4,%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 56 da b4 f4 00 00 00 10\s+vsm4key4 0x10000000\(%esp,%esi,8\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 56 da 31\s+vsm4key4 \(%ecx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 56 da b1 e0 0f 00 00\s+vsm4key4 0xfe0\(%ecx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 56 da b2 00 f0 ff ff\s+vsm4key4 -0x1000\(%edx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 52 da b4 f4 00 00 00 10\s+vsm4key4 0x10000000\(%esp,%esi,8\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 52 da 31\s+vsm4key4 \(%ecx\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 52 da b1 f0 07 00 00\s+vsm4key4 0x7f0\(%ecx\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 52 da b2 00 f8 ff ff\s+vsm4key4 -0x800\(%edx\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 57 da f4\s+vsm4rnds4 %ymm4,%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 53 da f4\s+vsm4rnds4 %xmm4,%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 57 da b4 f4 00 00 00 10\s+vsm4rnds4 0x10000000\(%esp,%esi,8\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 57 da 31\s+vsm4rnds4 \(%ecx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 57 da b1 e0 0f 00 00\s+vsm4rnds4 0xfe0\(%ecx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 57 da b2 00 f0 ff ff\s+vsm4rnds4 -0x1000\(%edx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 53 da b4 f4 00 00 00 10\s+vsm4rnds4 0x10000000\(%esp,%esi,8\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 53 da 31\s+vsm4rnds4 \(%ecx\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 53 da b1 f0 07 00 00\s+vsm4rnds4 0x7f0\(%ecx\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 53 da b2 00 f8 ff ff\s+vsm4rnds4 -0x800\(%edx\),%xmm5,%xmm6
diff --git a/gas/testsuite/gas/i386/sm4.s b/gas/testsuite/gas/i386/sm4.s
new file mode 100644
index 00000000000..0eb7b2fcb7b
--- /dev/null
+++ b/gas/testsuite/gas/i386/sm4.s
@@ -0,0 +1,47 @@
+# Check 32bit SM4 instructions
+
+	.allow_index_reg
+	.text
+_start:
+	vsm4key4	%ymm4, %ymm5, %ymm6
+	vsm4key4	%xmm4, %xmm5, %xmm6
+	vsm4key4	0x10000000(%esp, %esi, 8), %ymm5, %ymm6
+	vsm4key4	(%ecx), %ymm5, %ymm6
+	vsm4key4	4064(%ecx), %ymm5, %ymm6
+	vsm4key4	-4096(%edx), %ymm5, %ymm6
+	vsm4key4	0x10000000(%esp, %esi, 8), %xmm5, %xmm6
+	vsm4key4	(%ecx), %xmm5, %xmm6
+	vsm4key4	2032(%ecx), %xmm5, %xmm6
+	vsm4key4	-2048(%edx), %xmm5, %xmm6
+	vsm4rnds4	%ymm4, %ymm5, %ymm6
+	vsm4rnds4	%xmm4, %xmm5, %xmm6
+	vsm4rnds4	0x10000000(%esp, %esi, 8), %ymm5, %ymm6
+	vsm4rnds4	(%ecx), %ymm5, %ymm6
+	vsm4rnds4	4064(%ecx), %ymm5, %ymm6
+	vsm4rnds4	-4096(%edx), %ymm5, %ymm6
+	vsm4rnds4	0x10000000(%esp, %esi, 8), %xmm5, %xmm6
+	vsm4rnds4	(%ecx), %xmm5, %xmm6
+	vsm4rnds4	2032(%ecx), %xmm5, %xmm6
+	vsm4rnds4	-2048(%edx), %xmm5, %xmm6
+
+.intel_syntax noprefix
+	vsm4key4	ymm6, ymm5, ymm4
+	vsm4key4	xmm6, xmm5, xmm4
+	vsm4key4	ymm6, ymm5, YMMWORD PTR [esp+esi*8+0x10000000]
+	vsm4key4	ymm6, ymm5, YMMWORD PTR [ecx]
+	vsm4key4	ymm6, ymm5, YMMWORD PTR [ecx+4064]
+	vsm4key4	ymm6, ymm5, YMMWORD PTR [edx-4096]
+	vsm4key4	xmm6, xmm5, XMMWORD PTR [esp+esi*8+0x10000000]
+	vsm4key4	xmm6, xmm5, XMMWORD PTR [ecx]
+	vsm4key4	xmm6, xmm5, XMMWORD PTR [ecx+2032]
+	vsm4key4	xmm6, xmm5, XMMWORD PTR [edx-2048]
+	vsm4rnds4	ymm6, ymm5, ymm4
+	vsm4rnds4	xmm6, xmm5, xmm4
+	vsm4rnds4	ymm6, ymm5, YMMWORD PTR [esp+esi*8+0x10000000]
+	vsm4rnds4	ymm6, ymm5, YMMWORD PTR [ecx]
+	vsm4rnds4	ymm6, ymm5, YMMWORD PTR [ecx+4064]
+	vsm4rnds4	ymm6, ymm5, YMMWORD PTR [edx-4096]
+	vsm4rnds4	xmm6, xmm5, XMMWORD PTR [esp+esi*8+0x10000000]
+	vsm4rnds4	xmm6, xmm5, XMMWORD PTR [ecx]
+	vsm4rnds4	xmm6, xmm5, XMMWORD PTR [ecx+2032]
+	vsm4rnds4	xmm6, xmm5, XMMWORD PTR [edx-2048]
diff --git a/gas/testsuite/gas/i386/x86-64-sm4-intel.d b/gas/testsuite/gas/i386/x86-64-sm4-intel.d
new file mode 100644
index 00000000000..9bfa59592ae
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-sm4-intel.d
@@ -0,0 +1,50 @@
+#as:
+#objdump: -dw -Mintel
+#name: x86_64 SM4 insns (Intel disassembly)
+#source: x86-64-sm4.s
+
+.*: +file format .*
+
+Disassembly of section \.text:
+
+0+ <_start>:
+\s*[a-f0-9]+:\s*c4 e2 56 da f4\s+vsm4key4 ymm6,ymm5,ymm4
+\s*[a-f0-9]+:\s*c4 e2 52 da f4\s+vsm4key4 xmm6,xmm5,xmm4
+\s*[a-f0-9]+:\s*c4 a2 56 da b4 f5 00 00 00 10\s+vsm4key4 ymm6,ymm5,YMMWORD PTR \[rbp\+r14\*8\+0x10000000\]
+\s*[a-f0-9]+:\s*c4 c2 56 da 31\s+vsm4key4 ymm6,ymm5,YMMWORD PTR \[r9\]
+\s*[a-f0-9]+:\s*c4 e2 56 da b1 e0 0f 00 00\s+vsm4key4 ymm6,ymm5,YMMWORD PTR \[rcx\+0xfe0\]
+\s*[a-f0-9]+:\s*c4 e2 56 da b2 00 f0 ff ff\s+vsm4key4 ymm6,ymm5,YMMWORD PTR \[rdx-0x1000\]
+\s*[a-f0-9]+:\s*c4 a2 52 da b4 f5 00 00 00 10\s+vsm4key4 xmm6,xmm5,XMMWORD PTR \[rbp\+r14\*8\+0x10000000\]
+\s*[a-f0-9]+:\s*c4 c2 52 da 31\s+vsm4key4 xmm6,xmm5,XMMWORD PTR \[r9\]
+\s*[a-f0-9]+:\s*c4 e2 52 da b1 f0 07 00 00\s+vsm4key4 xmm6,xmm5,XMMWORD PTR \[rcx\+0x7f0\]
+\s*[a-f0-9]+:\s*c4 e2 52 da b2 00 f8 ff ff\s+vsm4key4 xmm6,xmm5,XMMWORD PTR \[rdx-0x800\]
+\s*[a-f0-9]+:\s*c4 e2 57 da f4\s+vsm4rnds4 ymm6,ymm5,ymm4
+\s*[a-f0-9]+:\s*c4 e2 53 da f4\s+vsm4rnds4 xmm6,xmm5,xmm4
+\s*[a-f0-9]+:\s*c4 a2 57 da b4 f5 00 00 00 10\s+vsm4rnds4 ymm6,ymm5,YMMWORD PTR \[rbp\+r14\*8\+0x10000000\]
+\s*[a-f0-9]+:\s*c4 c2 57 da 31\s+vsm4rnds4 ymm6,ymm5,YMMWORD PTR \[r9\]
+\s*[a-f0-9]+:\s*c4 e2 57 da b1 e0 0f 00 00\s+vsm4rnds4 ymm6,ymm5,YMMWORD PTR \[rcx\+0xfe0\]
+\s*[a-f0-9]+:\s*c4 e2 57 da b2 00 f0 ff ff\s+vsm4rnds4 ymm6,ymm5,YMMWORD PTR \[rdx-0x1000\]
+\s*[a-f0-9]+:\s*c4 a2 53 da b4 f5 00 00 00 10\s+vsm4rnds4 xmm6,xmm5,XMMWORD PTR \[rbp\+r14\*8\+0x10000000\]
+\s*[a-f0-9]+:\s*c4 c2 53 da 31\s+vsm4rnds4 xmm6,xmm5,XMMWORD PTR \[r9\]
+\s*[a-f0-9]+:\s*c4 e2 53 da b1 f0 07 00 00\s+vsm4rnds4 xmm6,xmm5,XMMWORD PTR \[rcx\+0x7f0\]
+\s*[a-f0-9]+:\s*c4 e2 53 da b2 00 f8 ff ff\s+vsm4rnds4 xmm6,xmm5,XMMWORD PTR \[rdx-0x800\]
+\s*[a-f0-9]+:\s*c4 e2 56 da f4\s+vsm4key4 ymm6,ymm5,ymm4
+\s*[a-f0-9]+:\s*c4 e2 52 da f4\s+vsm4key4 xmm6,xmm5,xmm4
+\s*[a-f0-9]+:\s*c4 a2 56 da b4 f5 00 00 00 10\s+vsm4key4 ymm6,ymm5,YMMWORD PTR \[rbp\+r14\*8\+0x10000000\]
+\s*[a-f0-9]+:\s*c4 c2 56 da 31\s+vsm4key4 ymm6,ymm5,YMMWORD PTR \[r9\]
+\s*[a-f0-9]+:\s*c4 e2 56 da b1 e0 0f 00 00\s+vsm4key4 ymm6,ymm5,YMMWORD PTR \[rcx\+0xfe0\]
+\s*[a-f0-9]+:\s*c4 e2 56 da b2 00 f0 ff ff\s+vsm4key4 ymm6,ymm5,YMMWORD PTR \[rdx-0x1000\]
+\s*[a-f0-9]+:\s*c4 a2 52 da b4 f5 00 00 00 10\s+vsm4key4 xmm6,xmm5,XMMWORD PTR \[rbp\+r14\*8\+0x10000000\]
+\s*[a-f0-9]+:\s*c4 c2 52 da 31\s+vsm4key4 xmm6,xmm5,XMMWORD PTR \[r9\]
+\s*[a-f0-9]+:\s*c4 e2 52 da b1 f0 07 00 00\s+vsm4key4 xmm6,xmm5,XMMWORD PTR \[rcx\+0x7f0\]
+\s*[a-f0-9]+:\s*c4 e2 52 da b2 00 f8 ff ff\s+vsm4key4 xmm6,xmm5,XMMWORD PTR \[rdx-0x800\]
+\s*[a-f0-9]+:\s*c4 e2 57 da f4\s+vsm4rnds4 ymm6,ymm5,ymm4
+\s*[a-f0-9]+:\s*c4 e2 53 da f4\s+vsm4rnds4 xmm6,xmm5,xmm4
+\s*[a-f0-9]+:\s*c4 a2 57 da b4 f5 00 00 00 10\s+vsm4rnds4 ymm6,ymm5,YMMWORD PTR \[rbp\+r14\*8\+0x10000000\]
+\s*[a-f0-9]+:\s*c4 c2 57 da 31\s+vsm4rnds4 ymm6,ymm5,YMMWORD PTR \[r9\]
+\s*[a-f0-9]+:\s*c4 e2 57 da b1 e0 0f 00 00\s+vsm4rnds4 ymm6,ymm5,YMMWORD PTR \[rcx\+0xfe0\]
+\s*[a-f0-9]+:\s*c4 e2 57 da b2 00 f0 ff ff\s+vsm4rnds4 ymm6,ymm5,YMMWORD PTR \[rdx-0x1000\]
+\s*[a-f0-9]+:\s*c4 a2 53 da b4 f5 00 00 00 10\s+vsm4rnds4 xmm6,xmm5,XMMWORD PTR \[rbp\+r14\*8\+0x10000000\]
+\s*[a-f0-9]+:\s*c4 c2 53 da 31\s+vsm4rnds4 xmm6,xmm5,XMMWORD PTR \[r9\]
+\s*[a-f0-9]+:\s*c4 e2 53 da b1 f0 07 00 00\s+vsm4rnds4 xmm6,xmm5,XMMWORD PTR \[rcx\+0x7f0\]
+\s*[a-f0-9]+:\s*c4 e2 53 da b2 00 f8 ff ff\s+vsm4rnds4 xmm6,xmm5,XMMWORD PTR \[rdx-0x800\]
diff --git a/gas/testsuite/gas/i386/x86-64-sm4.d b/gas/testsuite/gas/i386/x86-64-sm4.d
new file mode 100644
index 00000000000..2c1f6737d9a
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-sm4.d
@@ -0,0 +1,50 @@
+#as:
+#objdump: -dw
+#name: x86_64 SM4 insns
+#source: x86-64-sm4.s
+
+.*: +file format .*
+
+Disassembly of section \.text:
+
+0+ <_start>:
+\s*[a-f0-9]+:\s*c4 e2 56 da f4\s+vsm4key4 %ymm4,%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 52 da f4\s+vsm4key4 %xmm4,%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 a2 56 da b4 f5 00 00 00 10\s+vsm4key4 0x10000000\(%rbp,%r14,8\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 c2 56 da 31\s+vsm4key4 \(%r9\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 56 da b1 e0 0f 00 00\s+vsm4key4 0xfe0\(%rcx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 56 da b2 00 f0 ff ff\s+vsm4key4 -0x1000\(%rdx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 a2 52 da b4 f5 00 00 00 10\s+vsm4key4 0x10000000\(%rbp,%r14,8\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 c2 52 da 31\s+vsm4key4 \(%r9\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 52 da b1 f0 07 00 00\s+vsm4key4 0x7f0\(%rcx\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 52 da b2 00 f8 ff ff\s+vsm4key4 -0x800\(%rdx\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 57 da f4\s+vsm4rnds4 %ymm4,%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 53 da f4\s+vsm4rnds4 %xmm4,%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 a2 57 da b4 f5 00 00 00 10\s+vsm4rnds4 0x10000000\(%rbp,%r14,8\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 c2 57 da 31\s+vsm4rnds4 \(%r9\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 57 da b1 e0 0f 00 00\s+vsm4rnds4 0xfe0\(%rcx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 57 da b2 00 f0 ff ff\s+vsm4rnds4 -0x1000\(%rdx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 a2 53 da b4 f5 00 00 00 10\s+vsm4rnds4 0x10000000\(%rbp,%r14,8\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 c2 53 da 31\s+vsm4rnds4 \(%r9\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 53 da b1 f0 07 00 00\s+vsm4rnds4 0x7f0\(%rcx\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 53 da b2 00 f8 ff ff\s+vsm4rnds4 -0x800\(%rdx\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 56 da f4\s+vsm4key4 %ymm4,%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 52 da f4\s+vsm4key4 %xmm4,%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 a2 56 da b4 f5 00 00 00 10\s+vsm4key4 0x10000000\(%rbp,%r14,8\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 c2 56 da 31\s+vsm4key4 \(%r9\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 56 da b1 e0 0f 00 00\s+vsm4key4 0xfe0\(%rcx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 56 da b2 00 f0 ff ff\s+vsm4key4 -0x1000\(%rdx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 a2 52 da b4 f5 00 00 00 10\s+vsm4key4 0x10000000\(%rbp,%r14,8\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 c2 52 da 31\s+vsm4key4 \(%r9\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 52 da b1 f0 07 00 00\s+vsm4key4 0x7f0\(%rcx\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 52 da b2 00 f8 ff ff\s+vsm4key4 -0x800\(%rdx\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 57 da f4\s+vsm4rnds4 %ymm4,%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 53 da f4\s+vsm4rnds4 %xmm4,%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 a2 57 da b4 f5 00 00 00 10\s+vsm4rnds4 0x10000000\(%rbp,%r14,8\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 c2 57 da 31\s+vsm4rnds4 \(%r9\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 57 da b1 e0 0f 00 00\s+vsm4rnds4 0xfe0\(%rcx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 e2 57 da b2 00 f0 ff ff\s+vsm4rnds4 -0x1000\(%rdx\),%ymm5,%ymm6
+\s*[a-f0-9]+:\s*c4 a2 53 da b4 f5 00 00 00 10\s+vsm4rnds4 0x10000000\(%rbp,%r14,8\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 c2 53 da 31\s+vsm4rnds4 \(%r9\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 53 da b1 f0 07 00 00\s+vsm4rnds4 0x7f0\(%rcx\),%xmm5,%xmm6
+\s*[a-f0-9]+:\s*c4 e2 53 da b2 00 f8 ff ff\s+vsm4rnds4 -0x800\(%rdx\),%xmm5,%xmm6
diff --git a/gas/testsuite/gas/i386/x86-64-sm4.s b/gas/testsuite/gas/i386/x86-64-sm4.s
new file mode 100644
index 00000000000..cc680cb1a89
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-sm4.s
@@ -0,0 +1,47 @@
+# Check 64bit SM4 instructions
+
+	.allow_index_reg
+	.text
+_start:
+	vsm4key4	%ymm4, %ymm5, %ymm6 
+	vsm4key4	%xmm4, %xmm5, %xmm6
+	vsm4key4	0x10000000(%rbp, %r14, 8), %ymm5, %ymm6
+	vsm4key4	(%r9), %ymm5, %ymm6
+	vsm4key4	4064(%rcx), %ymm5, %ymm6
+	vsm4key4	-4096(%rdx), %ymm5, %ymm6
+	vsm4key4	0x10000000(%rbp, %r14, 8), %xmm5, %xmm6
+	vsm4key4	(%r9), %xmm5, %xmm6
+	vsm4key4	2032(%rcx), %xmm5, %xmm6
+	vsm4key4	-2048(%rdx), %xmm5, %xmm6
+	vsm4rnds4	%ymm4, %ymm5, %ymm6
+	vsm4rnds4	%xmm4, %xmm5, %xmm6
+	vsm4rnds4	0x10000000(%rbp, %r14, 8), %ymm5, %ymm6
+	vsm4rnds4	(%r9), %ymm5, %ymm6
+	vsm4rnds4	4064(%rcx), %ymm5, %ymm6
+	vsm4rnds4	-4096(%rdx), %ymm5, %ymm6
+	vsm4rnds4	0x10000000(%rbp, %r14, 8), %xmm5, %xmm6
+	vsm4rnds4	(%r9), %xmm5, %xmm6
+	vsm4rnds4	2032(%rcx), %xmm5, %xmm6
+	vsm4rnds4	-2048(%rdx), %xmm5, %xmm6
+
+.intel_syntax noprefix
+	vsm4key4	ymm6, ymm5, ymm4
+	vsm4key4	xmm6, xmm5, xmm4
+	vsm4key4	ymm6, ymm5, YMMWORD PTR [rbp+r14*8+0x10000000]
+	vsm4key4	ymm6, ymm5, YMMWORD PTR [r9]
+	vsm4key4	ymm6, ymm5, YMMWORD PTR [rcx+4064]
+	vsm4key4	ymm6, ymm5, YMMWORD PTR [rdx-4096]
+	vsm4key4	xmm6, xmm5, XMMWORD PTR [rbp+r14*8+0x10000000]
+	vsm4key4	xmm6, xmm5, XMMWORD PTR [r9]
+	vsm4key4	xmm6, xmm5, XMMWORD PTR [rcx+2032]
+	vsm4key4	xmm6, xmm5, XMMWORD PTR [rdx-2048]
+	vsm4rnds4	ymm6, ymm5, ymm4
+	vsm4rnds4	xmm6, xmm5, xmm4
+	vsm4rnds4	ymm6, ymm5, YMMWORD PTR [rbp+r14*8+0x10000000]
+	vsm4rnds4	ymm6, ymm5, YMMWORD PTR [r9]
+	vsm4rnds4	ymm6, ymm5, YMMWORD PTR [rcx+4064]
+	vsm4rnds4	ymm6, ymm5, YMMWORD PTR [rdx-4096]
+	vsm4rnds4	xmm6, xmm5, XMMWORD PTR [rbp+r14*8+0x10000000]
+	vsm4rnds4	xmm6, xmm5, XMMWORD PTR [r9]
+	vsm4rnds4	xmm6, xmm5, XMMWORD PTR [rcx+2032]
+	vsm4rnds4	xmm6, xmm5, XMMWORD PTR [rdx-2048]
diff --git a/gas/testsuite/gas/i386/x86-64.exp b/gas/testsuite/gas/i386/x86-64.exp
index d31bb40b32b..386d3dfd456 100644
--- a/gas/testsuite/gas/i386/x86-64.exp
+++ b/gas/testsuite/gas/i386/x86-64.exp
@@ -445,6 +445,8 @@ run_dump_test "x86-64-sha512-intel"
 run_list_test "x86-64-sha512-inval"
 run_dump_test "x86-64-sm3"
 run_dump_test "x86-64-sm3-intel"
+run_dump_test "x86-64-sm4"
+run_dump_test "x86-64-sm4-intel"
 run_dump_test "x86-64-clzero"
 run_dump_test "x86-64-mwaitx-bdver4"
 run_list_test "x86-64-mwaitx-reg"
diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index 006e38a16a9..6a5b3b7571a 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -3972,8 +3972,9 @@ static const struct dis386 prefix_table[][4] = {
   /* PREFIX_VEX_0F38DA_W_0 */
   {
     { VEX_LEN_TABLE (VEX_LEN_0F38DA_W_0_P_0) },
-    { Bad_Opcode },
+    { "vsm4key4", { XM, Vex, EXx }, 0 },
     { VEX_LEN_TABLE (VEX_LEN_0F38DA_W_0_P_2) },
+    { "vsm4rnds4", { XM, Vex, EXx }, 0 },
   },
 
   /* PREFIX_VEX_0F38F5_L_0 */
diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c
index 11af743ffe7..a0614f92cda 100644
--- a/opcodes/i386-gen.c
+++ b/opcodes/i386-gen.c
@@ -218,6 +218,8 @@ static const dependency isa_dependencies[] =
     "AVX2" },
   { "SM3",
     "AVX" },
+  { "SM4",
+    "AVX2" },
   { "XSAVES",
     "XSAVEC" },
   { "XSAVEC",
@@ -344,6 +346,7 @@ static bitfield cpu_flags[] =
   BITFIELD (SHA),
   BITFIELD (SHA512),
   BITFIELD (SM3),
+  BITFIELD (SM4),
   BITFIELD (ClflushOpt),
   BITFIELD (XSAVES),
   BITFIELD (XSAVEC),
diff --git a/opcodes/i386-opc.h b/opcodes/i386-opc.h
index 256ed532211..68cbfaa95e5 100644
--- a/opcodes/i386-opc.h
+++ b/opcodes/i386-opc.h
@@ -179,6 +179,8 @@ enum
   CpuSHA512,
   /* SM3 instructions required.  */
   CpuSM3,
+  /* SM4 instructions required.  */
+  CpuSM4,
   /* CLFLUSHOPT instruction required */
   CpuClflushOpt,
   /* XSAVES/XRSTORS instruction required */
@@ -409,6 +411,7 @@ typedef union i386_cpu_flags
       unsigned int cpusha:1;
       unsigned int cpusha512:1;
       unsigned int cpusm3:1;
+      unsigned int cpusm4:1;
       unsigned int cpuclflushopt:1;
       unsigned int cpuxsaves:1;
       unsigned int cpuxsavec:1;
diff --git a/opcodes/i386-opc.tbl b/opcodes/i386-opc.tbl
index 653b1cbc587..fdb436e38df 100644
--- a/opcodes/i386-opc.tbl
+++ b/opcodes/i386-opc.tbl
@@ -2058,6 +2058,13 @@ vsm3msg2, 0x66da, SM3, Modrm|Space0F38|Vex128|VexVVVV|VexW0|NoSuf, { RegXMM|Unsp
 
 // SM3 instructions end.
 
+// SM4 instructions.
+
+vsm4key4, 0xf3da, SM4, Modrm|Space0F38|Vex|VexVVVV|VexW0|CheckOperandSize|NoSuf, { RegXMM|RegYMM|Unspecified|BaseIndex, RegXMM|RegYMM, RegXMM|RegYMM }
+vsm4rnds4, 0xf2da, SM4, Modrm|Space0F38|Vex|VexVVVV|VexW0|CheckOperandSize|NoSuf, { RegXMM|RegYMM|Unspecified|BaseIndex, RegXMM|RegYMM, RegXMM|RegYMM }
+
+// SM4 instructions end.
+
 // VPCLMULQDQ instructions
 
 vpclmulqdq, 0x6644, VPCLMULQDQ, Modrm|Vex256|Space0F3A|VexWIG|VexVVVV|NoSuf, { Imm8|Imm8S, Unspecified|BaseIndex|RegYMM, RegYMM, RegYMM }
