<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 - [X86] Failure to pull out common scaled address offset through select/cmov"
href="https://bugs.llvm.org/show_bug.cgi?id=51069">51069</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[X86] Failure to pull out common scaled address offset through select/cmov
</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>Windows NT
</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: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>llvm-dev@redking.me.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, pengfei.wang@intel.com, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre><a href="https://simd.godbolt.org/z/qsKWW1heG">https://simd.godbolt.org/z/qsKWW1heG</a>
void dec(int *base, long long offset, int sel) {
int *ptr0 = base + offset + 0;
int *ptr6 = base + offset + 6;
int *ptr = sel ? ptr0 : ptr6;
(*ptr)--;
}
define void @dec(i32* nocapture %0, i64 %1, i32 %2) {
%4 = getelementptr inbounds i32, i32* %0, i64 %1
%5 = getelementptr inbounds i32, i32* %4, i64 6
%6 = icmp eq i32 %2, 0
%7 = select i1 %6, i32* %5, i32* %4
%8 = load i32, i32* %7, align 4, !tbaa !3
%9 = add nsw i32 %8, -1
store i32 %9, i32* %7, align 4, !tbaa !3
ret void
}
dec:
leaq (%rdi,%rsi,4), %rax
leaq (%rdi,%rsi,4), %rcx
addq $24, %rcx
testl %edx, %edx
cmovneq %rax, %rcx
addl $-1, (%rcx)
retq
We can reduce the number of complex LEA ops by pulling the common "%rsi,4"
scaled offset through the cmov and into the addl address:
dec:
leaq 24(%rdi), %rcx
testl %edx, %edx
cmovneq %rdi, %rcx
addl $-1, (%rcx,%rsi,4)
retq
This might be generally achievable by canonicalizing the gep-chain, but for now
I'm making this a X86 ticket.</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>