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: unassignedb...@nondot.org
          Reporter: llvm-...@redking.me.uk
                CC: craig.top...@gmail.com, llvm-bugs@lists.llvm.org,
                    spatel+l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to