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

    <tr>
        <th>Summary</th>
        <td>
            The output type of atomic operation function is unsigned regardless of whether the input parameter is signed or unsigned
        </td>
    </tr>

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

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

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

<pre>
    source code 1:
Builtin atomic add operation function with int input type
```
__sync_fetch_and_add_8(int, int);
```
I got the assembly bundle code :
```
{
.reg    .s32 temp;
neg.s32     temp, %r5;
atom.global.add.u32     %r6, [%r1], %r5;
}
```
The return value is parsed to an unsigned 32 bit width type.

source code 2:
Builtin atomic add operation function with long input type
```
__sync_fetch_and_add_8(long, long);
```
The assembly bundle code :
```
{
.reg    .s64 temp;
neg.s64     temp, %rd2;
atom.global.add.u64     %rd3, [%r1], temp;
}
```
The return value is also parsed to an unsigned 64 bit width type.

Assume there is an atomic operation function, the return value of it is a binary complementary code with a value of 1111 1111. If this return value is parsed as signed value, the origin code would be 1000 0001 and the true value would be -1 (decimal). But if this return value is parsed as unsigned value, the origin code would be itself 1111 1111 and the true value would be 255 (decimal). Two results are different.

The other atomic operations don't distinguish type as well, like atomic "sub",  "or",  "xor" and "and". 
Can someone please explain why complier doesn't distinguish signed and unsigned return type for atomic operation funcitons? Wouldn't that go wrong?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysld9vozgQx_8a8zIqAhsS8sBD0yjSvle6x8jgAXxnbOQfzea_P9mh2W7T7OpWV1WA6_kO35nP4HLn5KgRW1LvSX3IePCTse18UeYN58sQdNYZcWmdCbZH6I1AKAl7JsWBFM_7IJWXGrg3s-yBCwFmQcu9NBqGoPv0cJZ-Aqk9SL0ED_6y4FVONsX6m5ank7vo_jSg76cT1-LEhTg1hDZSe0JfI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