<html>
<head>
<base href="https://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 - Constant Hoist Makes Inconsistent Code Generation"
href="https://bugs.llvm.org/show_bug.cgi?id=41554">41554</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Constant Hoist Makes Inconsistent Code Generation
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>7.0
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>manjian2006@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>#include <stdint.h>
struct MemChunk {
int a, flags;
};
void SlowFoo(void* a, void* b);
static const int kPageSizeBits = 19;
static inline MemChunk* ToMemChunk(void* o) {
uintptr_t i = reinterpret_cast<intptr_t>(o);
const int page_mask = ~((1 << kPageSizeBits) - 1);
i = i & page_mask;
return reinterpret_cast<MemChunk*>(i);
}
void foo(void* a, void* b) {
MemChunk* m_a = ToMemChunk(a);
if ((m_a->flags & 2) == 0)
return;
MemChunk* m_b = ToMemChunk(b);
if ((m_b->flags & 2) == 0)
return;
SlowFoo(a, b);
}
compiles with -target armv7-linux-androideabi -fPIC -O3 -mllvm -debug -S
-march=armv7-a -mfloat-abi=softfp -mfpu=neon -marm
--sysroot=/home/linzj/android-ndk-r13b/platforms/android-15/arch-arm/
--gcc-toolchain=/home/linzj/android-ndk-r13b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/
-fomit-frame-pointer -fvisibility=hidden
And gen
mov r2, #4
mov r3, r0
bfi r3, r2, #0, #19
ldrb r2, [r3]
tst r2, #2
bxeq lr
movw r2, #0
movt r2, #65528
and r2, r1, r2
ldrb r2, [r2, #4]
tst r2, #2
bne .LBB0_2
@ %bb.1:
bx lr
.LBB0_2:
b _Z7SlowFooPvS_
note that the first and is combined as bfi instruction, but the second one
would not.
I think
mov r2, #4
mov r3, r0
bfi r3, r2, #0, #19
ldrb r3, [r3]
tst r3, #2
bxeq lr
mov r3, r1
bfi r3, r2, #0, #19
ldrb r2, [r3]
tst r2, #2
bne .LBB0_2
@ %bb.1: @ %cleanup7
bx lr
.LBB0_2: @ %if.end6
b _Z7SlowFooPvS_
is better output.</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>