[llvm-bugs] [Bug 36304] New: [Regression] sub nsw i32 %x, -1 gets transformed into add i32 %0, 2147483647 illegally
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Feb 8 10:21:22 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=36304
Bug ID: 36304
Summary: [Regression] sub nsw i32 %x, -1 gets transformed into
add i32 %0, 2147483647 illegally
Product: new-bugs
Version: 6.0
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: arphaman at gmail.com
CC: llvm-bugs at lists.llvm.org
LLVM transforms the 'sub nsw i32 %x, -1' instruction into 'add i32 %0,
2147483647' illegally.
Reproducer:
$ cat test.cpp
typedef unsigned long size_t;
void *memcpy(void *__dst, const void *__src, size_t __n);
int Execute(int &minSize, char *Output, const char *Input) {
for (int d=0; d<64; ++d) {
for (int s=0; s<64; ++s) {
for (int n=0; n<3; ++n) {
size_t len = minSize + (n*0x11389737 & minSize-1);
memcpy(Output+d, Input+s, len);
}
}
}
return 0;
}
$ ~/u/b/bin/clang repr.cpp -S -Xclang -emit-llvm -O1 -o ir.ll
$ cat ir.ll
Bad pass: "Combine redundant instructions"
...
%mul = mul nuw nsw i32 %n.028, 288921399
%sub = add i32 %0, 2147483647
%and = and i32 %sub, %mul
...
--
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/20180208/39108393/attachment.html>
More information about the llvm-bugs
mailing list