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: [email protected]
          Reporter: [email protected]
                CC: [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to