[PATCH] D146216: [lld][ELF] Relax long jump/call to short jump/call on AVR

Ben Shi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 12 20:03:34 PDT 2023


benshi001 added a comment.

In D146216#4263682 <https://reviews.llvm.org/D146216#4263682>, @MaskRay wrote:

> Increasing the number of instructions, while it may improve performance for some processors (any number?), doesn't look right...



1. On all devices, `long jump` costs 4 bytes, and `short jump + nop` also cost four bytes, there is no space expansion or shrink.
2. As AVR instruction manual indicates, short jump costs 2 cycles, while long jump costs 3 cycles. So one CPU cycle is saved.

For example,

  long jump _foo ; this is an unconditional jump which costs 4 bytes and 3 cpu cycle
  ...
  short jump _foo; this is an unconditional jump which costs 2 bytes and 2 cpu cycle 
  nop            ; this `nop` is just for padding the space of the replaced `long jump` , it is never executed.

In the above contrast, the `nop` is never executed, so `short jump + nop` does not waste any space, but saves one CPU cycle.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146216/new/

https://reviews.llvm.org/D146216



More information about the llvm-commits mailing list