[llvm-bugs] [Bug 50842] New: [X86] Failure to pull out common scaled index from address math
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jun 24 07:44:53 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50842
Bug ID: 50842
Summary: [X86] Failure to pull out common scaled index from
address math
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: llvm-dev at redking.me.uk
CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
llvm-dev at redking.me.uk, pengfei.wang at intel.com,
spatel+llvm at rotateright.com
https://c.godbolt.org/z/qd1EqKcdT
#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
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210624/cdedce5e/attachment.html>
More information about the llvm-bugs
mailing list