<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - Failure to re-use immediate shared between compare and subtract"
href="https://llvm.org/bugs/show_bug.cgi?id=28674">28674</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Failure to re-use immediate shared between compare and subtract
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>simon.hosie@arm.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Given:
uint32_t f(uint32_t x) { x++; return x < 4000569407 ? x : x - 4000569407; }
Compiling with:
clang --target=arm-linux-gnueabihf -O3 -S -o- p1modk.c
I get:
ldr r2, .LCPI2_0 // =294397890
ldr r3, .LCPI2_1 // =4000569407
add r1, r0, #1
cmp r1, r3
addhs r1, r0, r2
mov r0, r1
I expect:
ldr r1, .LCPI2_1 // =4000569407
add r0, r0, #1
cmp r0, r1
subhs r0, r0, r1
Or possibly (unless I made a mistake):
ldr r1, .LCPI2_1 // =(4000569407 - 1)
subs r1, r0, r1
addlo r1, r0, #1
mov r0, r1
Seems to affect at least x86, ARM, and AArch64.</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>