This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by atanasyan on Aug 21 2019, 1:39 PM.

Details

Summary

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)

Diff Detail

Repository
rL LLVM