Issue |
141627
|
Summary |
[RISCV] Unsigned atomics use signed load + zero-extension instead of unsigned loads
|
Labels |
new issue
|
Assignees |
|
Reporter |
tom-rein
|
The following code ([godbolt](https://godbolt.org/z/raqnhrGxa)):
```C++
#include <atomic>
unsigned char load(std::atomic_uchar &x) {
return x.load(std::memory_order_relaxed);
}
```
Compiles into:
```
load(std::atomic<unsigned char>&):
lb a0, 0(a0)
andi a0, a0, 255
ret
```
Instead of:
```
load(std::atomic<unsigned char>&):
lbu a0, 0(a0)
ret
```
Same is the case for `unsigned short` and signed atomics casted to unsigned.
For `unsigned int` signed load is correct because of the ABI, but when it is zero-extended, llvm fails to combine the zero-extension with the load.
Non-atomic loads correctly result in unsigned loads.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs