[LLVMbugs] [Bug 21771] New: consecutive stores not merged optimally

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Dec 5 14:15:28 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=21771

            Bug ID: 21771
           Summary: consecutive stores not merged optimally
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Marking this as an x86 bug, but it probably applies to any target that has
reasonably fast unaligned memops (and therefore could be fixed at a higher
level):

$ cat bad_store_merge.ll 
define <4 x double> @bad_store_merge(double* %ptr) {
  %a = load double* %ptr, align 8
  %vecinit = insertelement <4 x double> undef, double %a, i32 0
  %arrayidx1 = getelementptr inbounds double* %ptr, i64 1
  %b = load double* %arrayidx1, align 8
  %vecinit2 = insertelement <4 x double> %vecinit, double %b, i32 1
  %arrayidx3 = getelementptr inbounds double* %ptr, i64 2
  %c = load double* %arrayidx3, align 8
  %vecinit4 = insertelement <4 x double> %vecinit2, double %c, i32 2
  %arrayidx5 = getelementptr inbounds double* %ptr, i64 3
  %d = load double* %arrayidx5, align 8
  %vecinit6 = insertelement <4 x double> %vecinit4, double %d, i32 3
  ret <4 x double> %vecinit6
}

bin$ ./llc -mcpu=core2 bad_store_merge.ll -o -
...
    movsd    16(%rdi), %xmm1
    movhpd    24(%rdi), %xmm1
    movups    (%rdi), %xmm0
    retq


We should have combined the 'movsd' and 'movhpd' into one store, so the ideal
codegen for this target (not AVX, so no 256-bit memops) would be:

    movups    (%rdi), %xmm0
    movups    16(%rdi), %xmm1
    retq

This is a follow-on from bug 21710. I think it's a problem in
SelectionDAG::isConsecutiveLoad().

-- 
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/20141205/bc1dfbaa/attachment.html>


More information about the llvm-bugs mailing list