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)