| Issue |
183662
|
| Summary |
[hexagon] ror64 gets incorrect results at -O1
|
| Labels |
new issue
|
| Assignees |
androm3da
|
| Reporter |
androm3da
|
This program (reduced from code used in [Highway](https://github.com/google/highway/)) gets the wrong result on hexagon using llvm/clang 21.1.8.
$ hexagon-linux-musl-clang++ -mv73 -O1 -o ror64_bug ror64_bug.cc
$ qemu-hexagon ./ror64_bug
```
// Expected: ror64(val, 0) == val
// Actual: ror64(val, 0) == 0xFFFFFFFFFFFFFFFF (all-ones, for negative val)
#include <stdint.h>
#include <stdio.h>
volatile uint64_t gval = 0xD3C8835FBD1A89BAULL;
volatile uint64_t gamt = 0;
__attribute__((noinline))
uint64_t ror64(uint64_t val, uint64_t amt) {
uint64_t shr_amt = amt & 63;
uint64_t shl_amt = (0ULL - amt) & 63;
return (val >> shr_amt) | (val << shl_amt);
}
int main() {
uint64_t r = ror64(gval, gamt);
printf("result = 0x%016llx\n", (unsigned long long)r);
printf("expect = 0x%016llx\n", (unsigned long long)(uint64_t)gval);
return r != gval;
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs