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

    <tr>
        <th>Summary</th>
        <td>
            Inline assembly allocated register clash with multi-register constraints
        </td>
    </tr>

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

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

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

<pre>
    Consider the following minimum example (provided by Joseph C. Sible at the bugzilla origin):

```
void f(void) {
  asm volatile(
    "nop     # x is in %0 and y is in %1"
    :: "cd" (123), "cd" (456)
  );
}
```
With clang trunk (tested today on godbolt) there is no different registers assigned to two values as expected, with optimization levels from -O1 to -O3:
```
f():
        movl    $456, %ecx
        nop     # x is in %ecx and y is in %ecx
        retq
```
With -O0, there are two different load instructions compiled in.

My original example was more verbose but closer to the original exploded code:
```
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
 unsigned arg1 = strtoul(argv[1], NULL, 0);
  unsigned arg2 = strtoul(argv[2], NULL, 0);
  asm(
    "mov %[arg1], %%ecx\n\t"
 "add %[arg2], %[arg1]\n\t"
    "add %[arg2], %%ecx\n\t"
 "rcl $0, %%ecx"
    : [arg1] "+&abdSD" (arg1), [arg2] "+&abdSD" (arg2)
    :
    : "cc", "ecx");
  printf("%u %u\n", arg1, arg2);
}
```
With all levels from -O0 to -O3 it assigns the same register to arg1 and arg2.

GCC renders these statements correctly, different registers in all cases.

The first Clang version at which I've detected the issue is 6.0.

This is a clone of https://bugs.llvm.org/show_bug.cgi?id=48862, copying from now closed LLVM bugzilla.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVluT4jYT_TXipWso0-ZiHniYgY-vNjWbfdhcHlOy1NhKZIlIshn216fa9nKZHVKZmsJG8lF3nz59jIzRVI5oIxYvYrGbyDbVPmwcJVUX2aT0-rzZeheNpgCp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