<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 index from address math"
href="https://bugs.llvm.org/show_bug.cgi?id=50842">50842</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[X86] Failure to pull out common scaled index from address math
</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://c.godbolt.org/z/qd1EqKcdT">https://c.godbolt.org/z/qd1EqKcdT</a>
#include <stdint.h>
#include <stdio.h>
struct PayLoad {
float *f32;
double *f64;
int32_t *i32;
int64_t *i64;
};
size_t MoveEntry(PayLoad &data, size_t to, size_t N) {
size_t from = N - 1;
if (to < from) {
data.f32[to] = data.f32[from];
data.f64[to] = data.f64[from];
data.i32[to] = data.i32[from];
data.i64[to] = data.i64[from];
}
return N - 1;
}
The 'from' addresses all have a fixed offset from the %rdx scaled index that
could be removed if we used the %rax for the scaled index directly.
clang -g0 -O3
MoveEntry:
leaq -1(%rdx), %rax
cmpq %rsi, %rax
jbe .LBB0_2
movq (%rdi), %rcx
movss -4(%rcx,%rdx,4), %xmm0
movss %xmm0, (%rcx,%rsi,4)
movq 8(%rdi), %rcx
movsd -8(%rcx,%rdx,8), %xmm0
movsd %xmm0, (%rcx,%rsi,8)
movq 16(%rdi), %r8
movl -4(%r8,%rdx,4), %ecx
movl %ecx, (%r8,%rsi,4)
movq 24(%rdi), %rcx
movq -8(%rcx,%rdx,8), %rdx
movq %rdx, (%rcx,%rsi,8)
.LBB0_2:
retq
%struct.PayLoad = type { float*, double*, i32*, i64* }
define dso_local i64 @_Z9MoveEntryR7PayLoadmm(%struct.PayLoad* nocapture
nonnull readonly align 8 dereferenceable(32) %0, i64 %1, i64 %2)
local_unnamed_addr #0 {
%4 = add i64 %2, -1
%5 = icmp ugt i64 %4, %1
br i1 %5, label %6, label %27
6: ; preds = %3
%7 = getelementptr inbounds %struct.PayLoad, %struct.PayLoad* %0, i64 0, i32
0
%8 = load float*, float** %7, align 8, !tbaa !3
%9 = getelementptr inbounds float, float* %8, i64 %4
%10 = load float, float* %9, align 4, !tbaa !8
%11 = getelementptr inbounds float, float* %8, i64 %1
store float %10, float* %11, align 4, !tbaa !8
%12 = getelementptr inbounds %struct.PayLoad, %struct.PayLoad* %0, i64 0, i32
1
%13 = load double*, double** %12, align 8, !tbaa !10
%14 = getelementptr inbounds double, double* %13, i64 %4
%15 = load double, double* %14, align 8, !tbaa !11
%16 = getelementptr inbounds double, double* %13, i64 %1
store double %15, double* %16, align 8, !tbaa !11
%17 = getelementptr inbounds %struct.PayLoad, %struct.PayLoad* %0, i64 0, i32
2
%18 = load i32*, i32** %17, align 8, !tbaa !13
%19 = getelementptr inbounds i32, i32* %18, i64 %4
%20 = load i32, i32* %19, align 4, !tbaa !14
%21 = getelementptr inbounds i32, i32* %18, i64 %1
store i32 %20, i32* %21, align 4, !tbaa !14
%22 = getelementptr inbounds %struct.PayLoad, %struct.PayLoad* %0, i64 0, i32
3
%23 = load i64*, i64** %22, align 8, !tbaa !16
%24 = getelementptr inbounds i64, i64* %23, i64 %4
%25 = load i64, i64* %24, align 8, !tbaa !17
%26 = getelementptr inbounds i64, i64* %23, i64 %1
store i64 %25, i64* %26, align 8, !tbaa !17
br label %27
27: ; preds = %6, %3
ret i64 %4
}</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>