x86-64: further tighten convert-load-reloc checking

REX2.M affects what insn we're actually dealing with, so we better check
this to avoid transforming (future) insns we must not touch.
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 3d68f97..1e08f2e 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2354,14 +2354,14 @@
 	  if (to_reloc_pc32)
 	    return true;
 
-	  if (opcode == 0x85)
+	  if (opcode == 0x85 && !(rex2 & (REX2_M << 4)))
 	    {
 	      /* Convert "test %reg, foo@GOTPCREL(%rip)" to
 		 "test $foo, %reg".  */
 	      modrm = 0xc0 | (modrm & 0x38) >> 3;
 	      opcode = 0xf7;
 	    }
-	  else if ((opcode | 0x38) == 0x3b)
+	  else if ((opcode | 0x38) == 0x3b && !(rex2 & (REX2_M << 4)))
 	    {
 	      /* Convert "binop foo@GOTPCREL(%rip), %reg" to
 		 "binop $foo, %reg".  */
diff --git a/ld/testsuite/ld-x86-64/load4.d b/ld/testsuite/ld-x86-64/load4.d
index 190205e..fc9c0c6 100644
--- a/ld/testsuite/ld-x86-64/load4.d
+++ b/ld/testsuite/ld-x86-64/load4.d
@@ -7,7 +7,10 @@
 Disassembly of section .text:
 
 0+4000b0 <_start>:
-[ 	]*[a-f0-9]+:	12 05 ([0-9a-f]{2} ){4} *	adc    0x[a-f0-9]+\(%rip\),%al        # 6000c8 <.*>
-[ 	]*[a-f0-9]+:	44 84 3d ([0-9a-f]{2} ){4} *	test   %r15b,0x[a-f0-9]+\(%rip\)        # 6000c8 <.*>
-[ 	]*[a-f0-9]+:	48 87 05 ([0-9a-f]{2} ){4} *	xchg   %rax,0x[a-f0-9]+\(%rip\)        # 6000c8 <.*>
+[ 	]*[a-f0-9]+:	12 05 ([0-9a-f]{2} ){4} *	adc    0x[a-f0-9]+\(%rip\),%al        # 6000e0 <.*>
+[ 	]*[a-f0-9]+:	44 84 3d ([0-9a-f]{2} ){4} *	test   %r15b,0x[a-f0-9]+\(%rip\)        # 6000e0 <.*>
+[ 	]*[a-f0-9]+:	48 87 05 ([0-9a-f]{2} ){4} *	xchg   %rax,0x[a-f0-9]+\(%rip\)        # 6000e0 <.*>
+[ 	]*[a-f0-9]+:	d5 c0 03 05 ([0-9a-f]{2} ){4} *	lsl    0x[a-f0-9]+\(%rip\),%r16d        # 6000e0 <.*>
+[ 	]*[a-f0-9]+:	d5 80 13 05 ([0-9a-f]{2} ){4} *	\{rex2 0x80\} movlps %xmm0,0x[a-f0-9]+\(%rip\)        # 6000e0 <.*>
+[ 	]*[a-f0-9]+:	d5 80 2b 05 ([0-9a-f]{2} ){4} *	\{rex2 0x80\} movntps %xmm0,0x[a-f0-9]+\(%rip\)        # 6000e0 <.*>
 #pass
diff --git a/ld/testsuite/ld-x86-64/load4.s b/ld/testsuite/ld-x86-64/load4.s
index f3fa1b1..ab6f668 100644
--- a/ld/testsuite/ld-x86-64/load4.s
+++ b/ld/testsuite/ld-x86-64/load4.s
@@ -19,5 +19,11 @@
 1:	.reloc .-4, R_X86_64_REX_GOTPCRELX, bar-4
 	xchg	1f(%rip), %rax
 1:	.reloc .-4, R_X86_64_REX_GOTPCRELX, bar-4
+	lsl	1f(%rip), %r16d
+1:	.reloc .-4, R_X86_64_CODE_4_GOTPCRELX, bar-4
+	{rex2} movlps %xmm0, 1f(%rip)
+1:	.reloc .-4, R_X86_64_CODE_4_GOTPCRELX, bar-4
+	{rex2} movntps %xmm0, 1f(%rip)
+1:	.reloc .-4, R_X86_64_CODE_4_GOTPCRELX, bar-4
 
 	.size	_start, .-_start