# RUN: llvm-mc -triple x86_64 -show-encoding -x86-asm-syntax=intel -output-asm-variant=1 %s | FileCheck %s

# CHECK: {evex}	sar	bl, 123
# CHECK: encoding: [0x62,0xf4,0x7c,0x08,0xc0,0xfb,0x7b]
         {evex}	sar	bl, 123
# CHECK: {nf}	sar	bl, 123
# CHECK: encoding: [0x62,0xf4,0x7c,0x0c,0xc0,0xfb,0x7b]
         {nf}	sar	bl, 123
# CHECK: sar	bl, bl, 123
# CHECK: encoding: [0x62,0xf4,0x64,0x18,0xc0,0xfb,0x7b]
         sar	bl, bl, 123
# CHECK: {nf}	sar	bl, bl, 123
# CHECK: encoding: [0x62,0xf4,0x64,0x1c,0xc0,0xfb,0x7b]
         {nf}	sar	bl, bl, 123
# CHECK: {evex}	sar	dx, 123
# CHECK: encoding: [0x62,0xf4,0x7d,0x08,0xc1,0xfa,0x7b]
         {evex}	sar	dx, 123
# CHECK: {nf}	sar	dx, 123
# CHECK: encoding: [0x62,0xf4,0x7d,0x0c,0xc1,0xfa,0x7b]
         {nf}	sar	dx, 123
# CHECK: sar	dx, dx, 123
# CHECK: encoding: [0x62,0xf4,0x6d,0x18,0xc1,0xfa,0x7b]
         sar	dx, dx, 123
# CHECK: {nf}	sar	dx, dx, 123
# CHECK: encoding: [0x62,0xf4,0x6d,0x1c,0xc1,0xfa,0x7b]
         {nf}	sar	dx, dx, 123
# CHECK: {evex}	sar	ecx, 123
# CHECK: encoding: [0x62,0xf4,0x7c,0x08,0xc1,0xf9,0x7b]
         {evex}	sar	ecx, 123
# CHECK: {nf}	sar	ecx, 123
# CHECK: encoding: [0x62,0xf4,0x7c,0x0c,0xc1,0xf9,0x7b]
         {nf}	sar	ecx, 123
# CHECK: sar	ecx, ecx, 123
# CHECK: encoding: [0x62,0xf4,0x74,0x18,0xc1,0xf9,0x7b]
         sar	ecx, ecx, 123
# CHECK: {nf}	sar	ecx, ecx, 123
# CHECK: encoding: [0x62,0xf4,0x74,0x1c,0xc1,0xf9,0x7b]
         {nf}	sar	ecx, ecx, 123
# CHECK: {evex}	sar	r9, 123
# CHECK: encoding: [0x62,0xd4,0xfc,0x08,0xc1,0xf9,0x7b]
         {evex}	sar	r9, 123
# CHECK: {nf}	sar	r9, 123
# CHECK: encoding: [0x62,0xd4,0xfc,0x0c,0xc1,0xf9,0x7b]
         {nf}	sar	r9, 123
# CHECK: sar	r9, r9, 123
# CHECK: encoding: [0x62,0xd4,0xb4,0x18,0xc1,0xf9,0x7b]
         sar	r9, r9, 123
# CHECK: {nf}	sar	r9, r9, 123
# CHECK: encoding: [0x62,0xd4,0xb4,0x1c,0xc1,0xf9,0x7b]
         {nf}	sar	r9, r9, 123
# CHECK: {evex}	sar	byte ptr [r8 + 4*rax + 291], 123
# CHECK: encoding: [0x62,0xd4,0x7c,0x08,0xc0,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
         {evex}	sar	byte ptr [r8 + 4*rax + 291], 123
# CHECK: {nf}	sar	byte ptr [r8 + 4*rax + 291], 123
# CHECK: encoding: [0x62,0xd4,0x7c,0x0c,0xc0,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
         {nf}	sar	byte ptr [r8 + 4*rax + 291], 123
# CHECK: sar	bl, byte ptr [r8 + 4*rax + 291], 123
# CHECK: encoding: [0x62,0xd4,0x64,0x18,0xc0,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
         sar	bl, byte ptr [r8 + 4*rax + 291], 123
# CHECK: {nf}	sar	bl, byte ptr [r8 + 4*rax + 291], 123
# CHECK: encoding: [0x62,0xd4,0x64,0x1c,0xc0,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
         {nf}	sar	bl, byte ptr [r8 + 4*rax + 291], 123
# CHECK: {evex}	sar	word ptr [r8 + 4*rax + 291], 123
# CHECK: encoding: [0x62,0xd4,0x7d,0x08,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
         {evex}	sar	word ptr [r8 + 4*rax + 291], 123
# CHECK: {nf}	sar	word ptr [r8 + 4*rax + 291], 123
# CHECK: encoding: [0x62,0xd4,0x7d,0x0c,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
         {nf}	sar	word ptr [r8 + 4*rax + 291], 123
# CHECK: sar	dx, word ptr [r8 + 4*rax + 291], 123
# CHECK: encoding: [0x62,0xd4,0x6d,0x18,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
         sar	dx, word ptr [r8 + 4*rax + 291], 123
# CHECK: {nf}	sar	dx, word ptr [r8 + 4*rax + 291], 123
# CHECK: encoding: [0x62,0xd4,0x6d,0x1c,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
         {nf}	sar	dx, word ptr [r8 + 4*rax + 291], 123
# CHECK: {evex}	sar	dword ptr [r8 + 4*rax + 291], 123
# CHECK: encoding: [0x62,0xd4,0x7c,0x08,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
         {evex}	sar	dword ptr [r8 + 4*rax + 291], 123
# CHECK: {nf}	sar	dword ptr [r8 + 4*rax + 291], 123
# CHECK: encoding: [0x62,0xd4,0x7c,0x0c,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
         {nf}	sar	dword ptr [r8 + 4*rax + 291], 123
# CHECK: sar	ecx, dword ptr [r8 + 4*rax + 291], 123
# CHECK: encoding: [0x62,0xd4,0x74,0x18,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
         sar	ecx, dword ptr [r8 + 4*rax + 291], 123
# CHECK: {nf}	sar	ecx, dword ptr [r8 + 4*rax + 291], 123
# CHECK: encoding: [0x62,0xd4,0x74,0x1c,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
         {nf}	sar	ecx, dword ptr [r8 + 4*rax + 291], 123
# CHECK: {evex}	sar	qword ptr [r8 + 4*rax + 291], 123
# CHECK: encoding: [0x62,0xd4,0xfc,0x08,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
         {evex}	sar	qword ptr [r8 + 4*rax + 291], 123
# CHECK: {nf}	sar	qword ptr [r8 + 4*rax + 291], 123
# CHECK: encoding: [0x62,0xd4,0xfc,0x0c,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
         {nf}	sar	qword ptr [r8 + 4*rax + 291], 123
# CHECK: sar	r9, qword ptr [r8 + 4*rax + 291], 123
# CHECK: encoding: [0x62,0xd4,0xb4,0x18,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
         sar	r9, qword ptr [r8 + 4*rax + 291], 123
# CHECK: {nf}	sar	r9, qword ptr [r8 + 4*rax + 291], 123
# CHECK: encoding: [0x62,0xd4,0xb4,0x1c,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
         {nf}	sar	r9, qword ptr [r8 + 4*rax + 291], 123
# CHECK: {evex}	sar	bl
# CHECK: encoding: [0x62,0xf4,0x7c,0x08,0xd0,0xfb]
         {evex}	sar	bl
# CHECK: {nf}	sar	bl
# CHECK: encoding: [0x62,0xf4,0x7c,0x0c,0xd0,0xfb]
         {nf}	sar	bl
# CHECK: {evex}	sar	bl, cl
# CHECK: encoding: [0x62,0xf4,0x7c,0x08,0xd2,0xfb]
         {evex}	sar	bl, cl
# CHECK: {nf}	sar	bl, cl
# CHECK: encoding: [0x62,0xf4,0x7c,0x0c,0xd2,0xfb]
         {nf}	sar	bl, cl
# CHECK: sar	bl, bl, cl
# CHECK: encoding: [0x62,0xf4,0x64,0x18,0xd2,0xfb]
         sar	bl, bl, cl
# CHECK: {nf}	sar	bl, bl, cl
# CHECK: encoding: [0x62,0xf4,0x64,0x1c,0xd2,0xfb]
         {nf}	sar	bl, bl, cl
# CHECK: {evex}	sar	dx, cl
# CHECK: encoding: [0x62,0xf4,0x7d,0x08,0xd3,0xfa]
         {evex}	sar	dx, cl
# CHECK: {nf}	sar	dx, cl
# CHECK: encoding: [0x62,0xf4,0x7d,0x0c,0xd3,0xfa]
         {nf}	sar	dx, cl
# CHECK: sar	dx, dx, cl
# CHECK: encoding: [0x62,0xf4,0x6d,0x18,0xd3,0xfa]
         sar	dx, dx, cl
# CHECK: {nf}	sar	dx, dx, cl
# CHECK: encoding: [0x62,0xf4,0x6d,0x1c,0xd3,0xfa]
         {nf}	sar	dx, dx, cl
# CHECK: {evex}	sar	ecx, cl
# CHECK: encoding: [0x62,0xf4,0x7c,0x08,0xd3,0xf9]
         {evex}	sar	ecx, cl
# CHECK: {nf}	sar	ecx, cl
# CHECK: encoding: [0x62,0xf4,0x7c,0x0c,0xd3,0xf9]
         {nf}	sar	ecx, cl
# CHECK: sar	ecx, ecx, cl
# CHECK: encoding: [0x62,0xf4,0x74,0x18,0xd3,0xf9]
         sar	ecx, ecx, cl
# CHECK: {nf}	sar	ecx, ecx, cl
# CHECK: encoding: [0x62,0xf4,0x74,0x1c,0xd3,0xf9]
         {nf}	sar	ecx, ecx, cl
# CHECK: {evex}	sar	r9, cl
# CHECK: encoding: [0x62,0xd4,0xfc,0x08,0xd3,0xf9]
         {evex}	sar	r9, cl
# CHECK: {nf}	sar	r9, cl
# CHECK: encoding: [0x62,0xd4,0xfc,0x0c,0xd3,0xf9]
         {nf}	sar	r9, cl
# CHECK: sar	r9, r9, cl
# CHECK: encoding: [0x62,0xd4,0xb4,0x18,0xd3,0xf9]
         sar	r9, r9, cl
# CHECK: {nf}	sar	r9, r9, cl
# CHECK: encoding: [0x62,0xd4,0xb4,0x1c,0xd3,0xf9]
         {nf}	sar	r9, r9, cl
# CHECK: {evex}	sar	byte ptr [r8 + 4*rax + 291], cl
# CHECK: encoding: [0x62,0xd4,0x7c,0x08,0xd2,0xbc,0x80,0x23,0x01,0x00,0x00]
         {evex}	sar	byte ptr [r8 + 4*rax + 291], cl
# CHECK: {nf}	sar	byte ptr [r8 + 4*rax + 291], cl
# CHECK: encoding: [0x62,0xd4,0x7c,0x0c,0xd2,0xbc,0x80,0x23,0x01,0x00,0x00]
         {nf}	sar	byte ptr [r8 + 4*rax + 291], cl
# CHECK: sar	bl, byte ptr [r8 + 4*rax + 291], cl
# CHECK: encoding: [0x62,0xd4,0x64,0x18,0xd2,0xbc,0x80,0x23,0x01,0x00,0x00]
         sar	bl, byte ptr [r8 + 4*rax + 291], cl
# CHECK: {nf}	sar	bl, byte ptr [r8 + 4*rax + 291], cl
# CHECK: encoding: [0x62,0xd4,0x64,0x1c,0xd2,0xbc,0x80,0x23,0x01,0x00,0x00]
         {nf}	sar	bl, byte ptr [r8 + 4*rax + 291], cl
# CHECK: {evex}	sar	word ptr [r8 + 4*rax + 291], cl
# CHECK: encoding: [0x62,0xd4,0x7d,0x08,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
         {evex}	sar	word ptr [r8 + 4*rax + 291], cl
# CHECK: {nf}	sar	word ptr [r8 + 4*rax + 291], cl
# CHECK: encoding: [0x62,0xd4,0x7d,0x0c,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
         {nf}	sar	word ptr [r8 + 4*rax + 291], cl
# CHECK: sar	dx, word ptr [r8 + 4*rax + 291], cl
# CHECK: encoding: [0x62,0xd4,0x6d,0x18,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
         sar	dx, word ptr [r8 + 4*rax + 291], cl
# CHECK: {nf}	sar	dx, word ptr [r8 + 4*rax + 291], cl
# CHECK: encoding: [0x62,0xd4,0x6d,0x1c,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
         {nf}	sar	dx, word ptr [r8 + 4*rax + 291], cl
# CHECK: {evex}	sar	dword ptr [r8 + 4*rax + 291], cl
# CHECK: encoding: [0x62,0xd4,0x7c,0x08,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
         {evex}	sar	dword ptr [r8 + 4*rax + 291], cl
# CHECK: {nf}	sar	dword ptr [r8 + 4*rax + 291], cl
# CHECK: encoding: [0x62,0xd4,0x7c,0x0c,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
         {nf}	sar	dword ptr [r8 + 4*rax + 291], cl
# CHECK: sar	ecx, dword ptr [r8 + 4*rax + 291], cl
# CHECK: encoding: [0x62,0xd4,0x74,0x18,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
         sar	ecx, dword ptr [r8 + 4*rax + 291], cl
# CHECK: {nf}	sar	ecx, dword ptr [r8 + 4*rax + 291], cl
# CHECK: encoding: [0x62,0xd4,0x74,0x1c,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
         {nf}	sar	ecx, dword ptr [r8 + 4*rax + 291], cl
# CHECK: {evex}	sar	qword ptr [r8 + 4*rax + 291], cl
# CHECK: encoding: [0x62,0xd4,0xfc,0x08,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
         {evex}	sar	qword ptr [r8 + 4*rax + 291], cl
# CHECK: {nf}	sar	qword ptr [r8 + 4*rax + 291], cl
# CHECK: encoding: [0x62,0xd4,0xfc,0x0c,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
         {nf}	sar	qword ptr [r8 + 4*rax + 291], cl
# CHECK: sar	r9, qword ptr [r8 + 4*rax + 291], cl
# CHECK: encoding: [0x62,0xd4,0xb4,0x18,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
         sar	r9, qword ptr [r8 + 4*rax + 291], cl
# CHECK: {nf}	sar	r9, qword ptr [r8 + 4*rax + 291], cl
# CHECK: encoding: [0x62,0xd4,0xb4,0x1c,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
         {nf}	sar	r9, qword ptr [r8 + 4*rax + 291], cl
# CHECK: {evex}	sar	dx
# CHECK: encoding: [0x62,0xf4,0x7d,0x08,0xd1,0xfa]
         {evex}	sar	dx
# CHECK: {nf}	sar	dx
# CHECK: encoding: [0x62,0xf4,0x7d,0x0c,0xd1,0xfa]
         {nf}	sar	dx
# CHECK: sar	dx, dx
# CHECK: encoding: [0x62,0xf4,0x6d,0x18,0xd1,0xfa]
         sar	dx, dx
# CHECK: {nf}	sar	dx, dx
# CHECK: encoding: [0x62,0xf4,0x6d,0x1c,0xd1,0xfa]
         {nf}	sar	dx, dx
# CHECK: {evex}	sar	ecx
# CHECK: encoding: [0x62,0xf4,0x7c,0x08,0xd1,0xf9]
         {evex}	sar	ecx
# CHECK: {nf}	sar	ecx
# CHECK: encoding: [0x62,0xf4,0x7c,0x0c,0xd1,0xf9]
         {nf}	sar	ecx
# CHECK: sar	ecx, ecx
# CHECK: encoding: [0x62,0xf4,0x74,0x18,0xd1,0xf9]
         sar	ecx, ecx
# CHECK: {nf}	sar	ecx, ecx
# CHECK: encoding: [0x62,0xf4,0x74,0x1c,0xd1,0xf9]
         {nf}	sar	ecx, ecx
# CHECK: {evex}	sar	r9
# CHECK: encoding: [0x62,0xd4,0xfc,0x08,0xd1,0xf9]
         {evex}	sar	r9
# CHECK: {nf}	sar	r9
# CHECK: encoding: [0x62,0xd4,0xfc,0x0c,0xd1,0xf9]
         {nf}	sar	r9
# CHECK: sar	r9, r9
# CHECK: encoding: [0x62,0xd4,0xb4,0x18,0xd1,0xf9]
         sar	r9, r9
# CHECK: {nf}	sar	r9, r9
# CHECK: encoding: [0x62,0xd4,0xb4,0x1c,0xd1,0xf9]
         {nf}	sar	r9, r9
# CHECK: {evex}	sar	byte ptr [r8 + 4*rax + 291]
# CHECK: encoding: [0x62,0xd4,0x7c,0x08,0xd0,0xbc,0x80,0x23,0x01,0x00,0x00]
         {evex}	sar	byte ptr [r8 + 4*rax + 291]
# CHECK: {nf}	sar	byte ptr [r8 + 4*rax + 291]
# CHECK: encoding: [0x62,0xd4,0x7c,0x0c,0xd0,0xbc,0x80,0x23,0x01,0x00,0x00]
         {nf}	sar	byte ptr [r8 + 4*rax + 291]
# CHECK: sar	bl, byte ptr [r8 + 4*rax + 291]
# CHECK: encoding: [0x62,0xd4,0x64,0x18,0xd0,0xbc,0x80,0x23,0x01,0x00,0x00]
         sar	bl, byte ptr [r8 + 4*rax + 291]
# CHECK: {nf}	sar	bl, byte ptr [r8 + 4*rax + 291]
# CHECK: encoding: [0x62,0xd4,0x64,0x1c,0xd0,0xbc,0x80,0x23,0x01,0x00,0x00]
         {nf}	sar	bl, byte ptr [r8 + 4*rax + 291]
# CHECK: {evex}	sar	word ptr [r8 + 4*rax + 291]
# CHECK: encoding: [0x62,0xd4,0x7d,0x08,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
         {evex}	sar	word ptr [r8 + 4*rax + 291]
# CHECK: {nf}	sar	word ptr [r8 + 4*rax + 291]
# CHECK: encoding: [0x62,0xd4,0x7d,0x0c,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
         {nf}	sar	word ptr [r8 + 4*rax + 291]
# CHECK: sar	dx, word ptr [r8 + 4*rax + 291]
# CHECK: encoding: [0x62,0xd4,0x6d,0x18,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
         sar	dx, word ptr [r8 + 4*rax + 291]
# CHECK: {nf}	sar	dx, word ptr [r8 + 4*rax + 291]
# CHECK: encoding: [0x62,0xd4,0x6d,0x1c,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
         {nf}	sar	dx, word ptr [r8 + 4*rax + 291]
# CHECK: {evex}	sar	dword ptr [r8 + 4*rax + 291]
# CHECK: encoding: [0x62,0xd4,0x7c,0x08,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
         {evex}	sar	dword ptr [r8 + 4*rax + 291]
# CHECK: {nf}	sar	dword ptr [r8 + 4*rax + 291]
# CHECK: encoding: [0x62,0xd4,0x7c,0x0c,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
         {nf}	sar	dword ptr [r8 + 4*rax + 291]
# CHECK: sar	ecx, dword ptr [r8 + 4*rax + 291]
# CHECK: encoding: [0x62,0xd4,0x74,0x18,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
         sar	ecx, dword ptr [r8 + 4*rax + 291]
# CHECK: {nf}	sar	ecx, dword ptr [r8 + 4*rax + 291]
# CHECK: encoding: [0x62,0xd4,0x74,0x1c,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
         {nf}	sar	ecx, dword ptr [r8 + 4*rax + 291]
# CHECK: {evex}	sar	qword ptr [r8 + 4*rax + 291]
# CHECK: encoding: [0x62,0xd4,0xfc,0x08,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
         {evex}	sar	qword ptr [r8 + 4*rax + 291]
# CHECK: {nf}	sar	qword ptr [r8 + 4*rax + 291]
# CHECK: encoding: [0x62,0xd4,0xfc,0x0c,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
         {nf}	sar	qword ptr [r8 + 4*rax + 291]
# CHECK: sar	r9, qword ptr [r8 + 4*rax + 291]
# CHECK: encoding: [0x62,0xd4,0xb4,0x18,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
         sar	r9, qword ptr [r8 + 4*rax + 291]
# CHECK: {nf}	sar	r9, qword ptr [r8 + 4*rax + 291]
# CHECK: encoding: [0x62,0xd4,0xb4,0x1c,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
         {nf}	sar	r9, qword ptr [r8 + 4*rax + 291]
