]> granicus.if.org Git - llvm/commit
[mips] Reduce number of instructions used for loading a global symbol's value
authorSimon Atanasyan <simon@atanasyan.com>
Fri, 23 Aug 2019 13:36:24 +0000 (13:36 +0000)
committerSimon Atanasyan <simon@atanasyan.com>
Fri, 23 Aug 2019 13:36:24 +0000 (13:36 +0000)
commit8d2fb8809f1814e114c70a2e1bba2e4ea7413f27
treedaa55e42936c03316cbf3b12634ac60b87a38c99
parent024e1cd14e34e88d53b031e1eaf20ed7f4d19afa
[mips] Reduce number of instructions used for loading a global symbol's value

Now `lw/sw $reg, sym+offset` pseudo instructions for global symbol `sym`
are lowering into the following three instructions.
```
lw     $reg, %got(symbol)($gp)
addiu  $reg, $reg, offset
lw/sw  $reg, 0($reg)
```

It's possible to reduce the number of instructions by taking the offset
in account in the final `lw/sw` command. This patch implements that
optimization.
```
lw     $reg, %got(symbol)($gp)
lw/sw  $reg, offset($reg)
```

Differential Revision: https://reviews.llvm.org/D66553

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369756 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/Mips/AsmParser/MipsAsmParser.cpp
test/MC/Mips/mips-expansions.s
test/MC/Mips/mips64-expansions.s