From: Jan Beulich <jbeulich@suse.com>
To: Binutils <binutils@sourceware.org>
Cc: "H.J. Lu" <hjl.tools@gmail.com>
Subject: [PATCH 1/3] x86: respect {nooptimize} for LEA
Date: Fri, 27 Jan 2023 12:35:04 +0100 [thread overview]
Message-ID: <3162e04b-3063-ab0c-3596-963132fd6233@suse.com> (raw)
In-Reply-To: <bea7bb2c-0fa1-6bc3-fb5c-223facaf47a2@suse.com>
Dropping a meaningless segment prefix occurs outside of
optimize_encoding() and hence needs explicit checking for a request to
avoid any optimizations.
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -8159,7 +8159,7 @@ process_operands (void)
{
if (!quiet_warnings)
as_warn (_("segment override on `%s' is ineffectual"), insn_name (&i.tm));
- if (optimize)
+ if (optimize && !i.no_optimize)
{
i.seg[0] = NULL;
i.prefix[SEG_PREFIX] = 0;
--- a/gas/testsuite/gas/i386/lea-optimize.d
+++ b/gas/testsuite/gas/i386/lea-optimize.d
@@ -10,6 +10,7 @@ Disassembly of section .text:
0+ <start>:
[ ]*[0-9a-f]+:[ ]+8d 04 08[ ]+lea[ ]+\(%eax,%ecx(,1)?\),%eax
[ ]*[0-9a-f]+:[ ]+8d 04 08[ ]+lea[ ]+\(%eax,%ecx(,1)?\),%eax
+[ ]*[0-9a-f]+:[ ]+26 8d 04 01[ ]+lea[ ]+%es:\(%ecx,%eax(,1)?\),%eax
[ ]*[0-9a-f]+:[ ]+8d 48 01[ ]+lea[ ]+0x1\(%eax\),%ecx
[ ]*[0-9a-f]+:[ ]+8d 88 00 00 00 00[ ]+lea[ ]+0x0\(%eax\),%ecx
[ ]*[0-9a-f]+:[ ]+8d 0c 25 00 00 00 00[ ]+lea[ ]+0x0\(,(%eiz)?(,1)?\),%ecx
@@ -21,6 +22,7 @@ Disassembly of section .text:
[ ]*[0-9a-f]+:[ ]+8b c8[ ]+mov[ ]+%eax,%ecx
[ ]*[0-9a-f]+:[ ]+8b c8[ ]+mov[ ]+%eax,%ecx
[ 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\),%esi
[ ]*[0-9a-f]+:[ ]+67 8d 04[ ]+lea[ ]+\(%si\),%eax
--- a/gas/testsuite/gas/i386/lea.e
+++ b/gas/testsuite/gas/i386/lea.e
@@ -1,4 +1,6 @@
.*: Assembler messages:
.*:3: Warning: .* `lea' .*
.*:4: Warning: .* `lea' .*
-.*:19: Warning: .* `lea' .*
+.*:5: Warning: .* `lea' .*
+.*:20: Warning: .* `lea' .*
+.*:21: Warning: .* `lea' .*
--- a/gas/testsuite/gas/i386/lea.s
+++ b/gas/testsuite/gas/i386/lea.s
@@ -2,6 +2,7 @@
start:
lea %ss:(%eax,%ecx), %eax
ss lea (%eax,%ecx), %eax
+ {nooptimize} es lea (%ecx,%eax), %eax
.allow_index_reg
lea 1(%eax), %ecx
@@ -17,6 +18,7 @@ start:
lea (%eax), %ecx
lea 1-1(%eax), %ecx
lea %gs:(%eax), %ecx
+ {nooptimize} lea %fs:(%eax), %ecx
lea (%si), %eax
lea (%si), %esi
--- a/gas/testsuite/gas/i386/lea16-optimize.d
+++ b/gas/testsuite/gas/i386/lea16-optimize.d
@@ -10,6 +10,7 @@ Disassembly of section .text:
0+ <start>:
[ ]*[0-9a-f]+:[ ]+67 66 8d 04 08[ ]+lea[ ]+\(%eax,%ecx(,1)?\),%eax
[ ]*[0-9a-f]+:[ ]+67 66 8d 04 08[ ]+lea[ ]+\(%eax,%ecx(,1)?\),%eax
+[ ]*[0-9a-f]+:[ ]+26 67 66 8d 04 01[ ]+lea[ ]+%es:\(%ecx,%eax(,1)?\),%eax
[ ]*[0-9a-f]+:[ ]+67 66 8d 48 01[ ]+lea[ ]+0x1\(%eax\),%ecx
[ ]*[0-9a-f]+:[ ]+67 66 8d 88 00 00 00 00[ ]+lea[ ]+0x0\(%eax\),%ecx
[ ]*[0-9a-f]+:[ ]+67 66 8d 0c 25 00 00 00 00[ ]+addr32 lea[ ]+0x0,%ecx
@@ -21,6 +22,7 @@ Disassembly of section .text:
[ ]*[0-9a-f]+:[ ]+66 8b c8[ ]+mov[ ]+%eax,%ecx
[ ]*[0-9a-f]+:[ ]+66 8b c8[ ]+mov[ ]+%eax,%ecx
[ ]*[0-9a-f]+:[ ]+66 8b c8[ ]+mov[ ]+%eax,%ecx
+[ ]*[0-9a-f]+:[ ]+64 67 66 8d 08[ ]+lea[ ]+%fs:\(%eax\),%ecx
[ ]*[0-9a-f]+:[ ]+66 8d 04[ ]+lea[ ]+\(%si\),%eax
[ ]*[0-9a-f]+:[ ]+66 8d 34[ ]+lea[ ]+\(%si\),%esi
[ ]*[0-9a-f]+:[ ]+66 8d 04[ ]+lea[ ]+\(%si\),%eax
--- a/gas/testsuite/gas/i386/lea16-optimize2.d
+++ b/gas/testsuite/gas/i386/lea16-optimize2.d
@@ -10,6 +10,7 @@ Disassembly of section .text:
0+ <start>:
[ ]*[0-9a-f]+:[ ]+67 66 8d 04 08[ ]+lea[ ]+\(%eax,%ecx(,1)?\),%eax
[ ]*[0-9a-f]+:[ ]+67 66 8d 04 08[ ]+lea[ ]+\(%eax,%ecx(,1)?\),%eax
+[ ]*[0-9a-f]+:[ ]+26 67 66 8d 04 01[ ]+lea[ ]+%es:\(%ecx,%eax(,1)?\),%eax
[ ]*[0-9a-f]+:[ ]+67 66 8d 48 01[ ]+lea[ ]+0x1\(%eax\),%ecx
[ ]*[0-9a-f]+:[ ]+67 66 8d 88 00 00 00 00[ ]+lea[ ]+0x0\(%eax\),%ecx
[ ]*[0-9a-f]+:[ ]+67 66 8d 0c 25 00 00 00 00[ ]+addr32 lea[ ]+0x0,%ecx
@@ -21,6 +22,7 @@ Disassembly of section .text:
[ ]*[0-9a-f]+:[ ]+66 8b c8[ ]+mov[ ]+%eax,%ecx
[ ]*[0-9a-f]+:[ ]+66 8b c8[ ]+mov[ ]+%eax,%ecx
[ ]*[0-9a-f]+:[ ]+66 8b c8[ ]+mov[ ]+%eax,%ecx
+[ ]*[0-9a-f]+:[ ]+64 67 66 8d 08[ ]+lea[ ]+%fs:\(%eax\),%ecx
[ ]*[0-9a-f]+:[ ]+66 8d 04[ ]+lea[ ]+\(%si\),%eax
[ ]*[0-9a-f]+:[ ]+66 8d 34[ ]+lea[ ]+\(%si\),%esi
[ ]*[0-9a-f]+:[ ]+66 8d 04[ ]+lea[ ]+\(%si\),%eax
--- a/gas/testsuite/gas/i386/lea16.d
+++ b/gas/testsuite/gas/i386/lea16.d
@@ -10,6 +10,7 @@ Disassembly of section .text:
0+ <start>:
[ ]*[0-9a-f]+:[ ]+36 67 66 8d 04 08[ ]+lea[ ]+%ss:\(%eax,%ecx(,1)?\),%eax
[ ]*[0-9a-f]+:[ ]+36 67 66 8d 04 08[ ]+lea[ ]+%ss:\(%eax,%ecx(,1)?\),%eax
+[ ]*[0-9a-f]+:[ ]+26 67 66 8d 04 01[ ]+lea[ ]+%es:\(%ecx,%eax(,1)?\),%eax
[ ]*[0-9a-f]+:[ ]+67 66 8d 48 01[ ]+lea[ ]+0x1\(%eax\),%ecx
[ ]*[0-9a-f]+:[ ]+67 66 8d 88 00 00 00 00[ ]+lea[ ]+0x0\(%eax\),%ecx
[ ]*[0-9a-f]+:[ ]+67 66 8d 0c 25 00 00 00 00[ ]+addr32 lea[ ]+0x0,%ecx
@@ -21,6 +22,7 @@ Disassembly of section .text:
[ ]*[0-9a-f]+:[ ]+67 66 8d 08[ ]+lea[ ]+\(%eax\),%ecx
[ ]*[0-9a-f]+:[ ]+67 66 8d 08[ ]+lea[ ]+\(%eax\),%ecx
[ ]*[0-9a-f]+:[ ]+65 67 66 8d 08[ ]+lea[ ]+%gs:\(%eax\),%ecx
+[ ]*[0-9a-f]+:[ ]+64 67 66 8d 08[ ]+lea[ ]+%fs:\(%eax\),%ecx
[ ]*[0-9a-f]+:[ ]+66 8d 04[ ]+lea[ ]+\(%si\),%eax
[ ]*[0-9a-f]+:[ ]+66 8d 34[ ]+lea[ ]+\(%si\),%esi
[ ]*[0-9a-f]+:[ ]+66 8d 04[ ]+lea[ ]+\(%si\),%eax
next prev parent reply other threads:[~2023-01-27 11:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-27 11:34 [PATCH 0/3] x86: small adjustments to optimization logic Jan Beulich
2023-01-27 11:35 ` Jan Beulich [this message]
2023-01-27 11:35 ` [PATCH 2/3] x86-64: respect {nooptimize} when building VEX prefix Jan Beulich
2023-01-27 11:36 ` [PATCH 3/3] x86: drop LOCK from XCHG when optimizing Jan Beulich
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=3162e04b-3063-ab0c-3596-963132fd6233@suse.com \
--to=jbeulich@suse.com \
--cc=binutils@sourceware.org \
--cc=hjl.tools@gmail.com \
/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).