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

    <tr>
        <th>Summary</th>
        <td>
            [avr] Wrong operand in inline asm.
        </td>
    </tr>

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

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

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

<pre>
    Take the following C code:

```c++
char func (char *x)
{
    char c;
    __asm ("ld %0, %a1" : "=r" (c) : "x" (x));
    return c;
}
```
and compile with `--target=avr -Os -save-temps -mmcu=atmega2560`.  The generated assembly will read
```none
func:
        movw    r26, r24
        ;APP
        ld      r24, Y
        ;NO_APP
        ...
```
which is wrong code because `"x"` specifies register class with regs R26, R27.  But Y is R28, R29.

Strangely enough, `x` is moved to `r26` which is correct, but the operand printed for `%a1` is wrong.


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxtUk1v4yAQ_TX4gmI5-Cs--JA26nFbdSuteqqwPbbZxWABTtp_vwNOum610cQwMzDz5j0a3X3UL_wPUDcC7bWU-iLUQO9pqzsg6ZEkJ5LcvkWyWkvYnbcQbUduaL-olhJ2CA5hx3fCquul8nqO4i-kW5JuQm9v3E7-KmFMdrjJE8Lu_cr3GKKIAR1G0pMJLvbA2rfw-zUW-qFtKxtwi1GbdqQ8fRtkdbnqcNxpFhLoRbiRYma3c9wM4LAvPxu6e7R0Z_kZdg6mGffT1C4-5yYYOMtDtZjSF2RxAAWGO-gotxamRn5gVSkRD---9VdawRryBG7oriZ9vuBiWOHZMCz7zOA4x6enT1d24Vjmj71uD_14fNuei-P4v8NfRtGOVFh6MRqF97LTBlq-WPA8XDnGHbUztKIXYHGSQVgHKKXEEVfOMGbp8wr3mZXIxd3i6Kuv_OzF9dEq3j6nn85wNQDSA0ovwxhkL5J33wtvIQNIodM-5mnA6CfWVhsDrfM3Guzi366ekXQUcjZCee57bVb8_h2tFcOEXyBEUO-LoqySPC-qqKvTrkorHjnhJNQkv0PpSX6ivwI1tw5CoUmhAPWd4mgxsh6dm62Xjz2gDcjH0sT4pNCR8nxbdrPRvwPsB2HtAhY3-eFQZtFYV2mS5mXf5azL-nbPeV9mGS7dgfG-5U0keQPSelAoh4ILDSW8NPkpEjVLGNvvkwP-CxQ7aYokKbFYmWZpti9IlsDEhYw9jlibITJ1gNQsg8WkRD3tvySqKgYFgQNfny9u1Ka2K7nGNlHoXgf0fwECfTi6">