[llvm-bugs] [Bug 27546] New: Incorrect code generated with unusual bitvector sizes
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Apr 27 13:11:38 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=27546
Bug ID: 27546
Summary: Incorrect code generated with unusual bitvector sizes
Product: new-bugs
Version: 3.8
Hardware: PC
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: nitpicker2000 at gmail.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
Created attachment 16277
--> https://llvm.org/bugs/attachment.cgi?id=16277&action=edit
Bug test case
The attached LLVM assembly file demonstrates the bug. Certain code sequences
involving unusual bitvector sizes (i65, in particular) seem to generate
incorrect code.
In the attached file, the procedure @bug_proc performs some bit-manipulations
on its argument, which is supposed to result in the temporary %t5 containing
the original value zero extended to i65. This value is negated and returned.
The procedure @correct_proc does a zero extend directly and then negates and
returns. I claim both procedures should be semantically identical, which
should result in the main function always returning a 0 exit code. However,
this is not the case. For some arguments, and at some optimization levels,
these procedures differ and the program returns exit code -1. As best I can
tell, the attached program should not exhibit undefined behavior.
```
$ clang --version
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin15.4.0
Thread model: posix
$ clang -O0 -o bug bug.ll; ./bug; echo $?
255
$ clang -O1 -o bug bug.ll; ./bug; echo $?
255
$ clang -O2 -o bug bug.ll; ./bug; echo $?
0
$ clang -O3 -o bug bug.ll; ./bug; echo $?
0
$ clang -Os -o bug bug.ll; ./bug; echo $?
0
```
I get identical behavior from clang version 3.6.2 and clang 3.8.0 (installed
via Homebrew).
--
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/20160427/aab1748f/attachment.html>
More information about the llvm-bugs
mailing list