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

            Bug ID: 41456
           Summary: Suboptimal codegen for {x, y} ↦ {x+x, x+y}
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

https://godbolt.org/z/2GE_vO

-----
The code snippet

```
#include <xmmintrin.h>

__m128i example(const __m128i vec) {
    return (__m128i){2 * vec[0], vec[0] + vec[1]};
}
```

is compiled to code that unpacks and repacks the values to the general purpose
registers. This uses 7 instructions. However, the same could easily be achieved
using

```
example:
    vpbroadcastq xmm1, xmm0
    vpaddq xmm0, xmm0, xmm1
    ret
```.

Other instructions, instead of vpbroadcastq can also be used; like vmovddup,
vpermilpd, etc.

-- 
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