x86: optimize LEA
authorJan Beulich <jbeulich@suse.com>
Mon, 26 Apr 2021 08:37:30 +0000 (10:37 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 26 Apr 2021 08:37:30 +0000 (10:37 +0200)
commitfe134c656991cda74ab7bad80947930f666f8907
treeeca41b24b1d7416e13375c9dc9685b1ebf5b5a4e
parentb818855549013ba43e730e07f790e5cbfd16a757
x86: optimize LEA

Over the years I've seen a number of instances where people used

    lea     (%reg1), %reg2

or

    lea     symbol, %reg

despite the same thing being expressable via MOV. Since additionally
LEA often has restrictions towards the ports it can be issued to, while
MOV typically gets dealt with simply by register renaming, transform to
MOV when possible (without growing opcode size and without altering
involved relocation types).

Note that for Mach-O the new 64-bit testcases would fail (for
BFD_RELOC_X86_64_32S not having a representation), and hence get skipped
there.
16 files changed:
gas/ChangeLog
gas/config/tc-i386.c
gas/testsuite/gas/i386/i386.exp
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 [new file with mode: 0644]
gas/testsuite/gas/i386/lea16.s [new file with mode: 0644]
gas/testsuite/gas/i386/lea64-optimize.d [new file with mode: 0644]
gas/testsuite/gas/i386/lea64.d [new file with mode: 0644]
gas/testsuite/gas/i386/lea64.e [new file with mode: 0644]
gas/testsuite/gas/i386/lea64.s [new file with mode: 0644]
opcodes/ChangeLog
opcodes/i386-opc.tbl
opcodes/i386-tbl.h