[llvm-bugs] [Bug 42986] New: Load/store combine fails to merge complex address math

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 13 09:06:24 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42986

            Bug ID: 42986
           Summary: Load/store combine fails to merge complex address math
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: llvm-dev at redking.me.uk
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    spatel+llvm at rotateright.com

Current Codegen: https://godbolt.org/z/LnSMCV

void cpy(const float *src, float *dst,
         unsigned src_offset, unsigned dst_offset, unsigned dst_stride) {
    float x0 = src[src_offset + 0];
    float x1 = src[src_offset + 1];
    dst[dst_offset + dst_stride + 0] = x0;
    dst[dst_offset + dst_stride + 1] = x1;
}

We fail to recognise the sequential load/stores, and merge to a single i64/f64
load/store pair.

clang -g0 -O3 -march=btver2

cpy:
  movl %edx, %eax
  incl %edx
  movl (%rdi,%rax,4), %eax
  movl (%rdi,%rdx,4), %edx
  leal (%r8,%rcx), %edi
  movl %eax, (%rsi,%rdi,4)
  leal 1(%r8,%rcx), %eax
  movl %edx, (%rsi,%rax,4)
  retq

Th -Oz case is even worse:

clang -g0 -Oz -march=btver2 

cpy:
  movl %edx, %eax
  movl (%rdi,%rax,4), %eax
  pushq $1
  popq %r9
  addl %r9d, %edx
  addl %r8d, %ecx
  movl (%rdi,%rdx,4), %edx
  movl %eax, (%rsi,%rcx,4)
  addl %r9d, %ecx
  movl %edx, (%rsi,%rcx,4)
  retq

-- 
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/20190813/b60ae4f5/attachment.html>


More information about the llvm-bugs mailing list