# RUN: llvm-mc -triple x86_64 -show-encoding %s | FileCheck %s
# RUN: not llvm-mc -triple i386 -show-encoding %s 2>&1 | FileCheck %s --check-prefix=ERROR
# ERROR-COUNT-94: error:
# ERROR-NOT: error:
# CHECK: {evex} sarb $123, %bl
# CHECK: encoding: [0x62,0xf4,0x7c,0x08,0xc0,0xfb,0x7b]
{evex} sarb $123, %bl
# CHECK: {nf} sarb $123, %bl
# CHECK: encoding: [0x62,0xf4,0x7c,0x0c,0xc0,0xfb,0x7b]
{nf} sarb $123, %bl
# CHECK: sarb $123, %bl, %bl
# CHECK: encoding: [0x62,0xf4,0x64,0x18,0xc0,0xfb,0x7b]
sarb $123, %bl, %bl
# CHECK: {nf} sarb $123, %bl, %bl
# CHECK: encoding: [0x62,0xf4,0x64,0x1c,0xc0,0xfb,0x7b]
{nf} sarb $123, %bl, %bl
# CHECK: {evex} sarw $123, %dx
# CHECK: encoding: [0x62,0xf4,0x7d,0x08,0xc1,0xfa,0x7b]
{evex} sarw $123, %dx
# CHECK: {nf} sarw $123, %dx
# CHECK: encoding: [0x62,0xf4,0x7d,0x0c,0xc1,0xfa,0x7b]
{nf} sarw $123, %dx
# CHECK: sarw $123, %dx, %dx
# CHECK: encoding: [0x62,0xf4,0x6d,0x18,0xc1,0xfa,0x7b]
sarw $123, %dx, %dx
# CHECK: {nf} sarw $123, %dx, %dx
# CHECK: encoding: [0x62,0xf4,0x6d,0x1c,0xc1,0xfa,0x7b]
{nf} sarw $123, %dx, %dx
# CHECK: {evex} sarl $123, %ecx
# CHECK: encoding: [0x62,0xf4,0x7c,0x08,0xc1,0xf9,0x7b]
{evex} sarl $123, %ecx
# CHECK: {nf} sarl $123, %ecx
# CHECK: encoding: [0x62,0xf4,0x7c,0x0c,0xc1,0xf9,0x7b]
{nf} sarl $123, %ecx
# CHECK: sarl $123, %ecx, %ecx
# CHECK: encoding: [0x62,0xf4,0x74,0x18,0xc1,0xf9,0x7b]
sarl $123, %ecx, %ecx
# CHECK: {nf} sarl $123, %ecx, %ecx
# CHECK: encoding: [0x62,0xf4,0x74,0x1c,0xc1,0xf9,0x7b]
{nf} sarl $123, %ecx, %ecx
# CHECK: {evex} sarq $123, %r9
# CHECK: encoding: [0x62,0xd4,0xfc,0x08,0xc1,0xf9,0x7b]
{evex} sarq $123, %r9
# CHECK: {nf} sarq $123, %r9
# CHECK: encoding: [0x62,0xd4,0xfc,0x0c,0xc1,0xf9,0x7b]
{nf} sarq $123, %r9
# CHECK: sarq $123, %r9, %r9
# CHECK: encoding: [0x62,0xd4,0xb4,0x18,0xc1,0xf9,0x7b]
sarq $123, %r9, %r9
# CHECK: {nf} sarq $123, %r9, %r9
# CHECK: encoding: [0x62,0xd4,0xb4,0x1c,0xc1,0xf9,0x7b]
{nf} sarq $123, %r9, %r9
# CHECK: {evex} sarb $123, 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x7c,0x08,0xc0,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
{evex} sarb $123, 291(%r8,%rax,4)
# CHECK: {nf} sarb $123, 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x7c,0x0c,0xc0,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
{nf} sarb $123, 291(%r8,%rax,4)
# CHECK: sarb $123, 291(%r8,%rax,4), %bl
# CHECK: encoding: [0x62,0xd4,0x64,0x18,0xc0,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
sarb $123, 291(%r8,%rax,4), %bl
# CHECK: {nf} sarb $123, 291(%r8,%rax,4), %bl
# CHECK: encoding: [0x62,0xd4,0x64,0x1c,0xc0,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
{nf} sarb $123, 291(%r8,%rax,4), %bl
# CHECK: {evex} sarw $123, 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x7d,0x08,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
{evex} sarw $123, 291(%r8,%rax,4)
# CHECK: {nf} sarw $123, 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x7d,0x0c,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
{nf} sarw $123, 291(%r8,%rax,4)
# CHECK: sarw $123, 291(%r8,%rax,4), %dx
# CHECK: encoding: [0x62,0xd4,0x6d,0x18,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
sarw $123, 291(%r8,%rax,4), %dx
# CHECK: {nf} sarw $123, 291(%r8,%rax,4), %dx
# CHECK: encoding: [0x62,0xd4,0x6d,0x1c,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
{nf} sarw $123, 291(%r8,%rax,4), %dx
# CHECK: {evex} sarl $123, 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x7c,0x08,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
{evex} sarl $123, 291(%r8,%rax,4)
# CHECK: {nf} sarl $123, 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x7c,0x0c,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
{nf} sarl $123, 291(%r8,%rax,4)
# CHECK: sarl $123, 291(%r8,%rax,4), %ecx
# CHECK: encoding: [0x62,0xd4,0x74,0x18,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
sarl $123, 291(%r8,%rax,4), %ecx
# CHECK: {nf} sarl $123, 291(%r8,%rax,4), %ecx
# CHECK: encoding: [0x62,0xd4,0x74,0x1c,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
{nf} sarl $123, 291(%r8,%rax,4), %ecx
# CHECK: {evex} sarq $123, 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0xfc,0x08,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
{evex} sarq $123, 291(%r8,%rax,4)
# CHECK: {nf} sarq $123, 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0xfc,0x0c,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
{nf} sarq $123, 291(%r8,%rax,4)
# CHECK: sarq $123, 291(%r8,%rax,4), %r9
# CHECK: encoding: [0x62,0xd4,0xb4,0x18,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
sarq $123, 291(%r8,%rax,4), %r9
# CHECK: {nf} sarq $123, 291(%r8,%rax,4), %r9
# CHECK: encoding: [0x62,0xd4,0xb4,0x1c,0xc1,0xbc,0x80,0x23,0x01,0x00,0x00,0x7b]
{nf} sarq $123, 291(%r8,%rax,4), %r9
# CHECK: {evex} sarb %bl
# CHECK: encoding: [0x62,0xf4,0x7c,0x08,0xd0,0xfb]
{evex} sarb %bl
# CHECK: {nf} sarb %bl
# CHECK: encoding: [0x62,0xf4,0x7c,0x0c,0xd0,0xfb]
{nf} sarb %bl
# CHECK: {evex} sarb %cl, %bl
# CHECK: encoding: [0x62,0xf4,0x7c,0x08,0xd2,0xfb]
{evex} sarb %cl, %bl
# CHECK: {nf} sarb %cl, %bl
# CHECK: encoding: [0x62,0xf4,0x7c,0x0c,0xd2,0xfb]
{nf} sarb %cl, %bl
# CHECK: sarb %cl, %bl, %bl
# CHECK: encoding: [0x62,0xf4,0x64,0x18,0xd2,0xfb]
sarb %cl, %bl, %bl
# CHECK: {nf} sarb %cl, %bl, %bl
# CHECK: encoding: [0x62,0xf4,0x64,0x1c,0xd2,0xfb]
{nf} sarb %cl, %bl, %bl
# CHECK: {evex} sarw %cl, %dx
# CHECK: encoding: [0x62,0xf4,0x7d,0x08,0xd3,0xfa]
{evex} sarw %cl, %dx
# CHECK: {nf} sarw %cl, %dx
# CHECK: encoding: [0x62,0xf4,0x7d,0x0c,0xd3,0xfa]
{nf} sarw %cl, %dx
# CHECK: sarw %cl, %dx, %dx
# CHECK: encoding: [0x62,0xf4,0x6d,0x18,0xd3,0xfa]
sarw %cl, %dx, %dx
# CHECK: {nf} sarw %cl, %dx, %dx
# CHECK: encoding: [0x62,0xf4,0x6d,0x1c,0xd3,0xfa]
{nf} sarw %cl, %dx, %dx
# CHECK: {evex} sarl %cl, %ecx
# CHECK: encoding: [0x62,0xf4,0x7c,0x08,0xd3,0xf9]
{evex} sarl %cl, %ecx
# CHECK: {nf} sarl %cl, %ecx
# CHECK: encoding: [0x62,0xf4,0x7c,0x0c,0xd3,0xf9]
{nf} sarl %cl, %ecx
# CHECK: sarl %cl, %ecx, %ecx
# CHECK: encoding: [0x62,0xf4,0x74,0x18,0xd3,0xf9]
sarl %cl, %ecx, %ecx
# CHECK: {nf} sarl %cl, %ecx, %ecx
# CHECK: encoding: [0x62,0xf4,0x74,0x1c,0xd3,0xf9]
{nf} sarl %cl, %ecx, %ecx
# CHECK: {evex} sarq %cl, %r9
# CHECK: encoding: [0x62,0xd4,0xfc,0x08,0xd3,0xf9]
{evex} sarq %cl, %r9
# CHECK: {nf} sarq %cl, %r9
# CHECK: encoding: [0x62,0xd4,0xfc,0x0c,0xd3,0xf9]
{nf} sarq %cl, %r9
# CHECK: sarq %cl, %r9, %r9
# CHECK: encoding: [0x62,0xd4,0xb4,0x18,0xd3,0xf9]
sarq %cl, %r9, %r9
# CHECK: {nf} sarq %cl, %r9, %r9
# CHECK: encoding: [0x62,0xd4,0xb4,0x1c,0xd3,0xf9]
{nf} sarq %cl, %r9, %r9
# CHECK: {evex} sarb %cl, 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x7c,0x08,0xd2,0xbc,0x80,0x23,0x01,0x00,0x00]
{evex} sarb %cl, 291(%r8,%rax,4)
# CHECK: {nf} sarb %cl, 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x7c,0x0c,0xd2,0xbc,0x80,0x23,0x01,0x00,0x00]
{nf} sarb %cl, 291(%r8,%rax,4)
# CHECK: sarb %cl, 291(%r8,%rax,4), %bl
# CHECK: encoding: [0x62,0xd4,0x64,0x18,0xd2,0xbc,0x80,0x23,0x01,0x00,0x00]
sarb %cl, 291(%r8,%rax,4), %bl
# CHECK: {nf} sarb %cl, 291(%r8,%rax,4), %bl
# CHECK: encoding: [0x62,0xd4,0x64,0x1c,0xd2,0xbc,0x80,0x23,0x01,0x00,0x00]
{nf} sarb %cl, 291(%r8,%rax,4), %bl
# CHECK: {evex} sarw %cl, 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x7d,0x08,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
{evex} sarw %cl, 291(%r8,%rax,4)
# CHECK: {nf} sarw %cl, 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x7d,0x0c,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
{nf} sarw %cl, 291(%r8,%rax,4)
# CHECK: sarw %cl, 291(%r8,%rax,4), %dx
# CHECK: encoding: [0x62,0xd4,0x6d,0x18,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
sarw %cl, 291(%r8,%rax,4), %dx
# CHECK: {nf} sarw %cl, 291(%r8,%rax,4), %dx
# CHECK: encoding: [0x62,0xd4,0x6d,0x1c,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
{nf} sarw %cl, 291(%r8,%rax,4), %dx
# CHECK: {evex} sarl %cl, 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x7c,0x08,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
{evex} sarl %cl, 291(%r8,%rax,4)
# CHECK: {nf} sarl %cl, 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x7c,0x0c,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
{nf} sarl %cl, 291(%r8,%rax,4)
# CHECK: sarl %cl, 291(%r8,%rax,4), %ecx
# CHECK: encoding: [0x62,0xd4,0x74,0x18,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
sarl %cl, 291(%r8,%rax,4), %ecx
# CHECK: {nf} sarl %cl, 291(%r8,%rax,4), %ecx
# CHECK: encoding: [0x62,0xd4,0x74,0x1c,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
{nf} sarl %cl, 291(%r8,%rax,4), %ecx
# CHECK: {evex} sarq %cl, 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0xfc,0x08,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
{evex} sarq %cl, 291(%r8,%rax,4)
# CHECK: {nf} sarq %cl, 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0xfc,0x0c,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
{nf} sarq %cl, 291(%r8,%rax,4)
# CHECK: sarq %cl, 291(%r8,%rax,4), %r9
# CHECK: encoding: [0x62,0xd4,0xb4,0x18,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
sarq %cl, 291(%r8,%rax,4), %r9
# CHECK: {nf} sarq %cl, 291(%r8,%rax,4), %r9
# CHECK: encoding: [0x62,0xd4,0xb4,0x1c,0xd3,0xbc,0x80,0x23,0x01,0x00,0x00]
{nf} sarq %cl, 291(%r8,%rax,4), %r9
# CHECK: {evex} sarw %dx
# CHECK: encoding: [0x62,0xf4,0x7d,0x08,0xd1,0xfa]
{evex} sarw %dx
# CHECK: {nf} sarw %dx
# CHECK: encoding: [0x62,0xf4,0x7d,0x0c,0xd1,0xfa]
{nf} sarw %dx
# CHECK: sarw %dx, %dx
# CHECK: encoding: [0x62,0xf4,0x6d,0x18,0xd1,0xfa]
sarw %dx, %dx
# CHECK: {nf} sarw %dx, %dx
# CHECK: encoding: [0x62,0xf4,0x6d,0x1c,0xd1,0xfa]
{nf} sarw %dx, %dx
# CHECK: {evex} sarl %ecx
# CHECK: encoding: [0x62,0xf4,0x7c,0x08,0xd1,0xf9]
{evex} sarl %ecx
# CHECK: {nf} sarl %ecx
# CHECK: encoding: [0x62,0xf4,0x7c,0x0c,0xd1,0xf9]
{nf} sarl %ecx
# CHECK: sarl %ecx, %ecx
# CHECK: encoding: [0x62,0xf4,0x74,0x18,0xd1,0xf9]
sarl %ecx, %ecx
# CHECK: {nf} sarl %ecx, %ecx
# CHECK: encoding: [0x62,0xf4,0x74,0x1c,0xd1,0xf9]
{nf} sarl %ecx, %ecx
# CHECK: {evex} sarq %r9
# CHECK: encoding: [0x62,0xd4,0xfc,0x08,0xd1,0xf9]
{evex} sarq %r9
# CHECK: {nf} sarq %r9
# CHECK: encoding: [0x62,0xd4,0xfc,0x0c,0xd1,0xf9]
{nf} sarq %r9
# CHECK: sarq %r9, %r9
# CHECK: encoding: [0x62,0xd4,0xb4,0x18,0xd1,0xf9]
sarq %r9, %r9
# CHECK: {nf} sarq %r9, %r9
# CHECK: encoding: [0x62,0xd4,0xb4,0x1c,0xd1,0xf9]
{nf} sarq %r9, %r9
# CHECK: {evex} sarb 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x7c,0x08,0xd0,0xbc,0x80,0x23,0x01,0x00,0x00]
{evex} sarb 291(%r8,%rax,4)
# CHECK: {nf} sarb 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x7c,0x0c,0xd0,0xbc,0x80,0x23,0x01,0x00,0x00]
{nf} sarb 291(%r8,%rax,4)
# CHECK: sarb 291(%r8,%rax,4), %bl
# CHECK: encoding: [0x62,0xd4,0x64,0x18,0xd0,0xbc,0x80,0x23,0x01,0x00,0x00]
sarb 291(%r8,%rax,4), %bl
# CHECK: {nf} sarb 291(%r8,%rax,4), %bl
# CHECK: encoding: [0x62,0xd4,0x64,0x1c,0xd0,0xbc,0x80,0x23,0x01,0x00,0x00]
{nf} sarb 291(%r8,%rax,4), %bl
# CHECK: {evex} sarw 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x7d,0x08,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
{evex} sarw 291(%r8,%rax,4)
# CHECK: {nf} sarw 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x7d,0x0c,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
{nf} sarw 291(%r8,%rax,4)
# CHECK: sarw 291(%r8,%rax,4), %dx
# CHECK: encoding: [0x62,0xd4,0x6d,0x18,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
sarw 291(%r8,%rax,4), %dx
# CHECK: {nf} sarw 291(%r8,%rax,4), %dx
# CHECK: encoding: [0x62,0xd4,0x6d,0x1c,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
{nf} sarw 291(%r8,%rax,4), %dx
# CHECK: {evex} sarl 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x7c,0x08,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
{evex} sarl 291(%r8,%rax,4)
# CHECK: {nf} sarl 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x7c,0x0c,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
{nf} sarl 291(%r8,%rax,4)
# CHECK: sarl 291(%r8,%rax,4), %ecx
# CHECK: encoding: [0x62,0xd4,0x74,0x18,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
sarl 291(%r8,%rax,4), %ecx
# CHECK: {nf} sarl 291(%r8,%rax,4), %ecx
# CHECK: encoding: [0x62,0xd4,0x74,0x1c,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
{nf} sarl 291(%r8,%rax,4), %ecx
# CHECK: {evex} sarq 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0xfc,0x08,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
{evex} sarq 291(%r8,%rax,4)
# CHECK: {nf} sarq 291(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0xfc,0x0c,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
{nf} sarq 291(%r8,%rax,4)
# CHECK: sarq 291(%r8,%rax,4), %r9
# CHECK: encoding: [0x62,0xd4,0xb4,0x18,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
sarq 291(%r8,%rax,4), %r9
# CHECK: {nf} sarq 291(%r8,%rax,4), %r9
# CHECK: encoding: [0x62,0xd4,0xb4,0x1c,0xd1,0xbc,0x80,0x23,0x01,0x00,0x00]
{nf} sarq 291(%r8,%rax,4), %r9