x86: respect {nooptimize} for LEA
authorJan Beulich <jbeulich@suse.com>
Fri, 3 Feb 2023 07:22:12 +0000 (08:22 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 3 Feb 2023 07:22:12 +0000 (08:22 +0100)
Dropping a meaningless segment prefix occurs outside of
optimize_encoding() and hence needs explicit checking for a request to
avoid any optimizations.

gas/config/tc-i386.c
gas/testsuite/gas/i386/lea-optimize.d
gas/testsuite/gas/i386/lea.d
gas/testsuite/gas/i386/lea.e
gas/testsuite/gas/i386/lea.s
gas/testsuite/gas/i386/lea16-optimize.d
gas/testsuite/gas/i386/lea16-optimize2.d
gas/testsuite/gas/i386/lea16.d

index 235deb841c827e03708389d3a7a5ed451987479e..c3aa40b2a02a210fa24b3e6fe323e721f05cc636 100644 (file)
@@ -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;
index 283b994bbfcc2899225f61620473214c54833cb3..cec43322cce890baec327ece1dfa11c56e14f616 100644 (file)
@@ -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
 [      ]*[0-9a-f]+:[   ]+8b c8[        ]+mov[  ]+%eax,%ecx
+[      ]*[0-9a-f]+:[   ]+64 8d 08[     ]+lea[  ]+%fs:\(%eax\),%ecx
 [      ]*[0-9a-f]+:[   ]+0f b7 c6[     ]+movzwl[       ]+%si,%eax
 [      ]*[0-9a-f]+:[   ]+0f b7 f6[     ]+movzwl[       ]+%si,%esi
 [      ]*[0-9a-f]+:[   ]+0f b7 c6[     ]+movzwl[       ]+%si,%eax
index bfc9c13559a288ecbc8106acbde7ca12bc92dfc4..f6172696336288c9b150a68375b3dcf2559fee87 100644 (file)
@@ -9,6 +9,7 @@ Disassembly of section .text:
 0+ <start>:
 [      ]*[0-9a-f]+:[   ]+36 8d 04 08[  ]+lea[  ]+%ss:\(%eax,%ecx(,1)?\),%eax
 [      ]*[0-9a-f]+:[   ]+36 8d 04 08[  ]+lea[  ]+%ss:\(%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
@@ -20,6 +21,7 @@ Disassembly of section .text:
 [      ]*[0-9a-f]+:[   ]+8d 08[        ]+lea[  ]+\(%eax\),%ecx
 [      ]*[0-9a-f]+:[   ]+8d 08[        ]+lea[  ]+\(%eax\),%ecx
 [      ]*[0-9a-f]+:[   ]+65 8d 08[     ]+lea[  ]+%gs:\(%eax\),%ecx
+[      ]*[0-9a-f]+:[   ]+64 8d 08[     ]+lea[  ]+%fs:\(%eax\),%ecx
 [      ]*[0-9a-f]+:[   ]+67 8d 04[     ]+lea[  ]+\(%si\),%eax
 [      ]*[0-9a-f]+:[   ]+67 8d 34[     ]+lea[  ]+\(%si\),%esi
 [      ]*[0-9a-f]+:[   ]+67 8d 04[     ]+lea[  ]+\(%si\),%eax
index d0d47aeb3ebb9672c953f810fb0b03dd5e5542ca..dd8f606f34617408bd68d5539a0a26bb770525b1 100644 (file)
@@ -1,4 +1,6 @@
 .*: Assembler messages:
 .*:3: Warning: .* `lea' .*
 .*:4: Warning: .* `lea' .*
-.*:19: Warning: .* `lea' .*
+.*:5: Warning: .* `lea' .*
+.*:20: Warning: .* `lea' .*
+.*:21: Warning: .* `lea' .*
index 1fb6aa850034fd9e5bc319a263b2efc4e07e6471..f9f19a509cc93bfdb9722a9006638642e7c8762c 100644 (file)
@@ -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
index be3075886a8de9a452656f5ac66099fa58adf7fb..5585e8d53dd1c8c0d4d9d0f326cf946192251a53 100644 (file)
@@ -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
index d95f9acc640bd8dab53918eaf0be0c3e8b10d7ff..7afd97ed990410f5d2442501efea3a3e94258d1e 100644 (file)
@@ -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
index 179102adb09068d61d01f3f882a8b82d653b8529..f01010aefb757b32bb77abc010ba73fd27723d37 100644 (file)
@@ -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