[llvm-bugs] [Bug 40550] New: missed optimization: dead stores in after memcpy expansion

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 31 09:57:53 PST 2019


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

            Bug ID: 40550
           Summary: missed optimization: dead stores in after memcpy
                    expansion
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: clement.courbet at gmail.com
                CC: llvm-bugs at lists.llvm.org

Consider the following code:

```
struct S {
  char a[16];
};

void Swap(S& a, S& b) {
  S tmp = a;
  a = b;
  b = tmp;
}
```

The generated code goes through the stack and generates 3
load/store pairs:

```
        movups  (%rdi), %xmm0
        movaps  %xmm0, -24(%rsp)
        movups  (%rsi), %xmm0
        movups  %xmm0, (%rdi)
        movaps  -24(%rsp), %xmm0
        movups  %xmm0, (%rsi)
```

With -combiner-global-alias-analysis, the combiner can avoid going through the
stack, but still generates a dead store:

```
        movups  (%rdi), %xmm0
        movaps  %xmm0, -24(%rsp)
        movups  (%rsi), %xmm1
        movups  %xmm1, (%rdi)
        movups  %xmm0, (%rsi)
```

The following code would be much better:
```
        movups  (%rdi), %xmm0
        movups  (%rsi), %xmm1
        movups  %xmm1, (%rdi)
        movups  %xmm0, (%rsi)
```

-- 
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/20190131/1d1e9995/attachment.html>


More information about the llvm-bugs mailing list