<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/54508>54508</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [AVR] Optimize 'call' to 'rcall' for short programs
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          beenshi
      </td>
    </tr>
</table>

<pre>
    As a possible optimization, we  could look into using rcall instead of call instructions when the target is close enough. For example, here: https://godbolt.org/z/rEz9j71dq (apparently avr-gcc doesn't do this optimization).

```
int foo(int a, int b) {
    return a + b;
}

int bar(int a, int b) {
    return foo(a, b) + 3;
}
```

If -ffunction-sections is not used, rcall is both shorter in code size and faster in execution speed.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNU0uPnDAM_jXhYg2iPAY4cJjpdKWeKvXQe0gMZJtJaBz2Mb--hmHbbtVDEcR2HH_-bIfe69fuRCBh9kSmtwh-juZqbjIa70T-EZ4RQPnFarDefwfjooeFjBshKGktb1BEqcEP8MsOi1rDCZ4ndBAnhCjDiBEMgbKeEND5ZZxSePAB8EVeZ4trsgkDiuIEU4wzsSLyB35Hr3tvY-rDyNaNv_Dp1j7WH_QPEHkj51kGdNG-gnwKh1Ep0B6J2deRNc7Pad-X1aYiu4jstK_HbH83k0uEwXtGXjW58lqVnsNA1Of7IeAnYFyC4-aJ_MzuYneJ-vIn-hYrw3_D3VNv5-5nGLz4B_h70vf18wCHYVjc1v4D4T4Grt_5yGNDvcLugyPofZyAJh8iBibFc9YIZG4I0mkYJO37-IJqWaGAZkSdJrordFu0MokmWuxEdT59-yqqC3y5txmZdb1mYQF8YViEN3PgkW85YQ5-DPJKyRJs99fITZyWPlX-yoa1T2_iwDGPXBabhmhBYqUqq6xJpq6WSjfqqMsBG9WrBtu6KKpj1lSqRKXLxMoeLa1sRZ47fIYNgnVmnpguz_I8K_KCRVXWaS77NpODGtpG47GsRJnhVRqbrjzWu5iEbqPULyOx0xqK9Nsp-X8aHW7NWfHlErnorkd0NJlkS91t1H8Cngob4A">