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

            Bug ID: 39161
           Summary: Missed optimisation in shuffle operation on avx
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedb...@nondot.org
          Reporter: he...@dsprenkels.com
                CC: llvm-bugs@lists.llvm.org

I have the following C snippet:

```
__m256d example(__m256d x)
{
    __m256d ret = {};
    ret[0] = x[2];
    ret[1] = x[2];
    ret[2] = x[3];
    ret[3] = x[3];
    return ret;
}
```

which can be implemented using:

```
example:
  vperm2f128 ymm0, ymm0, ymm0, 0b00010001     ; [aa, bb, aa, bb]
  vpermilpd ymm0, ymm0, 0b1100                ; [aa, aa, bb, bb]
  ret
```

But LLVM compiles the code to:

```
example: # @example
  vextractf128 xmm0, ymm0, 1
  vmovddup xmm1, xmm0 # xmm1 = xmm0[0,0]
  vpermilpd xmm0, xmm0, 3 # xmm0 = xmm0[1,1]
  vinsertf128 ymm0, ymm1, xmm0, 1
  ret
```

Here's a link to the same snippet in godbolt: https://godbolt.org/z/NPYv_z

I would like to take a shot at fixing this myself, if this is not too hard to
implement. At least, if it's possible and desired by you guys.


At the moment of compilation, godbolt reported the following version
information:
```
clang version 8.0.0 (trunk 343649)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-trunk/bin
Compiler returned: 0
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to