<html>
<head>
<base href="http://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - 64-bit bitfield and/or miscompiled on ARM"
href="http://bugs.llvm.org/show_bug.cgi?id=32379">32379</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>64-bit bitfield and/or miscompiled on ARM
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: ARM
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>arielb1@mail.tau.ac.il
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>## Versions
This occurs on Debian's 3.9.1, Rust's fork of 3.9.1, and godbolt's 4.0 & trunk.
## STR
$ cat trouble.c
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
__attribute__((noinline))
uint64_t test_function(uint64_t data, bool f1, bool f2) {
if (f1) data &= ~2;
if (f2) data |= 2;
return data;
}
int main() {
int data = (int)test_function(2, false, false);
printf("%d\n", data);
return 0;
}
$ clang-3.9 test.c --target=armv7-unknown-linux-gnueabihf -O
$ ./a.out
0
$
## Expected Result
Code should print 2
## Actual Result
Code prints 0, as the following assembly is emitted:
test_function(unsigned long long, bool, bool):
mov r12, r0
cmp r2, #0
bfc r12, #1, #1
moveq r12, r0
bfi r12, r3, #1, #1
mov r0, r12
bx lr
The `bfi` instruction trashes the original value of r0.
This was originally reported as Rust bug
<a href="https://github.com/rust-lang/rust/issues/40593">https://github.com/rust-lang/rust/issues/40593</a>.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>