[PATCH] D66553: [mips] Reduce number of instructions used for loading a global symbol's value

Simon Atanasyan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 21 13:41:10 PDT 2019


atanasyan created this revision.
Herald added subscribers: jrtc27, hiraditya, arichardson, sdardis.
Herald added a project: LLVM.
atanasyan added a parent revision: D66228: [mips] Fix 64-bit address loading in case of applying 32-bit mask to the result.

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)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66553

Files:
  llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
  llvm/test/MC/Mips/mips-expansions.s
  llvm/test/MC/Mips/mips64-expansions.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66553.216465.patch
Type: text/x-patch
Size: 8588 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190821/3c25afff/attachment.bin>


More information about the llvm-commits mailing list