[llvm-bugs] [Bug 50118] New: llvm incorrectly compiles bitshift on x86
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Apr 25 15:28:08 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50118
Bug ID: 50118
Summary: llvm incorrectly compiles bitshift on x86
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: corydoras at ridiculousfish.com
CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
llvm-dev at redking.me.uk, pengfei.wang at intel.com,
spatel+llvm at rotateright.com
clang miscompiles a bit shift at -O1 when targeting x86-64 or i386.
To reproduce, on an x86 machine:
```
#include <stdio.h>
__attribute__((noinline))
unsigned func(unsigned v0, unsigned v1, unsigned shift) {
v1 <<= shift;
return v1 | (v0 >> ((32u - shift) & 31u));
}
int main(void) {
unsigned r = func(42, 0, 0);
printf("%u\n", r);
return 0;
}
```
Compile with `clang -O1 test.c && ./a.out`
This program should output 42, and it does so at -O0. However with -O1 it
outputs 0.
Reproes with clang 11.1 on Linux, clang 12.0 on x86 Mac. Does not repro with
clang 12 on ARM Mac. This does not repro on ARM so I'll direct to the x86
backend.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210425/936476c6/attachment.html>
More information about the llvm-bugs
mailing list