From: Jan Beulich <jbeulich@sourceware.org>
To: binutils-cvs@sourceware.org
Subject: [binutils-gdb] x86: %riz, %rip, and %eip don't require REX
Date: Fri, 21 Jun 2024 06:36:24 +0000 (GMT) [thread overview]
Message-ID: <20240621063625.DD0A63896C06@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8bcda53caab0308b5908dda68194ab5e3e2dd09d
commit 8bcda53caab0308b5908dda68194ab5e3e2dd09d
Author: Jan Beulich <jbeulich@suse.com>
Date: Fri Jun 21 08:35:23 2024 +0200
x86: %riz, %rip, and %eip don't require REX
While these can't be used as register operands, they can be used for
memory operand addressing. Such uses do not prevent conversion: The
RegRex64 checks in check_Rex_required() for base and index registers
were simply wrong. They specifically also aren't needed for byte
registers, as those won't pass i386_index_check() anyway.
Diff:
---
gas/config/tc-i386.c | 4 ++--
gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.d | 2 ++
gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.s | 3 +++
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index b8911c04436..e94b9370155 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -8683,8 +8683,8 @@ check_Rex_required (void)
return true;
}
- if ((i.index_reg && (i.index_reg->reg_flags & (RegRex | RegRex64)))
- || (i.base_reg && (i.base_reg->reg_flags & (RegRex | RegRex64))))
+ if ((i.index_reg && (i.index_reg->reg_flags & RegRex))
+ || (i.base_reg && (i.base_reg->reg_flags & RegRex)))
return true;
/* Check pseudo prefix {rex} are valid. */
diff --git a/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.d b/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.d
index 8069799f7fb..762d78be727 100644
--- a/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.d
+++ b/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.d
@@ -127,10 +127,12 @@ Disassembly of section .text:
\s*[a-f0-9]+:\s*62 74 3d 18 66 c0 adcx %eax,%r8d,%r8d
\s*[a-f0-9]+:\s*62 d4 7d 18 66 c7 adcx %r15d,%eax,%eax
\s*[a-f0-9]+:\s*67 66 0f 38 f6 04 0a adcx \(%edx,%ecx,1\),%eax
+\s*[a-f0-9]+:\s*66 0f 38 f6 04 22 adcx \(%rdx,%riz,1\),%eax
\s*[a-f0-9]+:\s*f3 0f 38 f6 c3 adox %ebx,%eax
\s*[a-f0-9]+:\s*f3 0f 38 f6 c3 adox %ebx,%eax
\s*[a-f0-9]+:\s*62 f4 fe 18 66 c3 adox %rbx,%rax,%rax
\s*[a-f0-9]+:\s*62 74 3e 18 66 c0 adox %eax,%r8d,%r8d
\s*[a-f0-9]+:\s*62 d4 7e 18 66 c7 adox %r15d,%eax,%eax
\s*[a-f0-9]+:\s*67 f3 0f 38 f6 04 0a adox \(%edx,%ecx,1\),%eax
+\s*[a-f0-9]+:\s*f3 0f 38 f6 05 00 00 00 00 adox (0x)?0\(%rip\),%eax[ ]+# .* sym.*
#pass
diff --git a/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.s b/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.s
index c83e1195d05..bf75e64622d 100644
--- a/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.s
+++ b/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.s
@@ -1,5 +1,6 @@
# Check 64bit APX NDD instructions with optimized encoding
+ .allow_index_reg
.text
_start:
add %r31,%r8,%r8
@@ -120,9 +121,11 @@ adcx %rbx,%rax,%rax
adcx %eax,%r8d,%r8d
adcx %r15d,%eax,%eax
adcx (%edx,%ecx,1),%eax,%eax
+adcx (%rdx,%riz,1),%eax,%eax
adox %ebx,%eax,%eax
adox %eax,%ebx,%eax
adox %rbx,%rax,%rax
adox %eax,%r8d,%r8d
adox %r15d,%eax,%eax
adox (%edx,%ecx,1),%eax,%eax
+adox sym(%rip),%eax,%eax
reply other threads:[~2024-06-21 6:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240621063625.DD0A63896C06@sourceware.org \
--to=jbeulich@sourceware.org \
--cc=binutils-cvs@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).