[llvm-bugs] [Bug 50141] New: Missing trunc(ctpop(zext(x))) -> ctpop(x) fold
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Apr 27 04:33:05 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50141
Bug ID: 50141
Summary: Missing trunc(ctpop(zext(x))) -> ctpop(x) fold
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: llvm-dev at redking.me.uk
CC: david.bolvansky at gmail.com, lebedev.ri at gmail.com,
llvm-bugs at lists.llvm.org, nikita.ppv at gmail.com,
spatel+llvm at rotateright.com
https://simd.godbolt.org/z/EcP4en5KG
#include <x86intrin.h>
__v8hu ctpop_int(__v8hu x) {
return (__v8hu) {
(unsigned short)__builtin_popcount( x[0] ),
(unsigned short)__builtin_popcount( x[1] ),
(unsigned short)__builtin_popcount( x[2] ),
(unsigned short)__builtin_popcount( x[3] ),
(unsigned short)__builtin_popcount( x[4] ),
(unsigned short)__builtin_popcount( x[5] ),
(unsigned short)__builtin_popcount( x[6] ),
(unsigned short)__builtin_popcount( x[7] )
};
}
define <8 x i16> @ctpop_int(<8 x i16> %0){
%2 = zext <8 x i16> %0 to <8 x i32>
%3 = call <8 x i32> @llvm.ctpop.v8i32(<8 x i32> %2)
%4 = trunc <8 x i32> %3 to <8 x i16>
ret <8 x i16> %4
}
declare <8 x i32> @llvm.ctpop.v8i32(<8 x i32>)
We should be able to just use a @llvm.ctpop.v8i16 call
Not sure if the trunc is vital, or whether we should also allow the fold:
ctpop(zext(x)) -> zext(ctpop(x))
--
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/20210427/7ca164a0/attachment.html>
More information about the llvm-bugs
mailing list