[llvm-bugs] [Bug 32719] New: Missed opportunity to eliminate copy due to suboptimal scheduling

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 20 04:40:26 PDT 2017


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

            Bug ID: 32719
           Summary: Missed opportunity to eliminate copy due to suboptimal
                    scheduling
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: zvi.rackover at intel.com
                CC: llvm-bugs at lists.llvm.org

Forking from https://reviews.llvm.org/D31961#inline-276908.

For the following equivalent functions:

 define <4 x i32> @foo(<4 x i32> %v, <4 x i32> *%p) {
   %a = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 2, i32 3,
i32 2, i32 3>
   %b = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 3, i32 3,
i32 3, i32 2>
   store <4 x i32> %a, <4 x i32>* %p
   ret <4 x i32> %b
 }

 define <4 x i32> @bar(<4 x i32> %v, <4 x i32> *%p) {
   %b = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 3, i32 3,
i32 3, i32 2>
   %a = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 2, i32 3,
i32 2, i32 3>
   store <4 x i32> %a, <4 x i32>* %p
   ret <4 x i32> %b
 }

llc -mcpu=skylake will generate

foo:
        vpshufd $238, %xmm0, %xmm1      # xmm1 = xmm0[2,3,2,3]
        vpshufd $191, %xmm0, %xmm0      # xmm0 = xmm0[3,3,3,2]
        vmovdqa %xmm1, (%rdi)
        retq
bar:
        vpshufd $191, %xmm0, %xmm1      # xmm1 = xmm0[3,3,3,2]
        vpshufd $238, %xmm0, %xmm0      # xmm0 = xmm0[2,3,2,3]
        vmovdqa %xmm0, (%rdi)
        vmovdqa %xmm1, %xmm0
        retq

Notice the extra copy in the function 'bar'.

Seems like we are sensitive to the scheduling that happens in Isel.

Is the post-RA scheduling, which we don't do for X86, supposed to handle this
case or is there another way to improve this case?

-- 
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/20170420/bf28a839/attachment-0001.html>


More information about the llvm-bugs mailing list