[llvm-bugs] [Bug 41456] New: Suboptimal codegen for {x, y} ↦ {x+x, x+y}
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Apr 10 12:17:33 PDT 2019
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: unassignedbugs at nondot.org
Reporter: hello at dsprenkels.com
CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
llvm-dev at redking.me.uk, spatel+llvm at rotateright.com
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190410/b18d2cd5/attachment.html>
More information about the llvm-bugs
mailing list