[llvm-bugs] [Bug 34047] New: Extra bitcasts prevent simplification of bit select
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Aug 3 09:09:06 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=34047
Bug ID: 34047
Summary: Extra bitcasts prevent simplification of bit select
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Common Code Generator Code
Assignee: unassignedbugs at nondot.org
Reporter: llvm-dev at redking.me.uk
CC: llvm-bugs at lists.llvm.org, spatel+llvm at rotateright.com
Two versions of the same 'select based on comparison' pattern, one using
generic vector types and the other using SSE intrinsics.
The presence of the bitcasts between SSE types prevents the recognition of the
select.
#include <x86intrin.h>
__v16qi cmp_i8_sel_v16i8(__v16qi a, __v16qi b, __v16qi c, __v16qi d) {
__v16qi cc = _mm_cmpeq_epi8(a, b);
return (c & ~cc) | (d & cc);
}
__m128i cmp_i8_sel_m128i(__m128i a, __m128i b, __m128i c, __m128i d) {
__m128i cc = _mm_cmpeq_epi8(a, b);
return _mm_or_si128(_mm_andnot_si128(cc, c), _mm_and_si128(cc, d));
}
define <16 x i8> @cmp_i8_sel_v16i8(<16 x i8>, <16 x i8>, <16 x i8>, <16 x i8>)
{
%5 = icmp eq <16 x i8> %0, %1
%6 = select <16 x i1> %5, <16 x i8> %3, <16 x i8> %2
ret <16 x i8> %6
}
define <2 x i64> @cmp_i8_sel_m128i(<2 x i64>, <2 x i64>, <2 x i64>, <2 x i64>)
{
%5 = bitcast <2 x i64> %0 to <16 x i8>
%6 = bitcast <2 x i64> %1 to <16 x i8>
%7 = icmp eq <16 x i8> %5, %6
%8 = sext <16 x i1> %7 to <16 x i8>
%9 = bitcast <16 x i8> %8 to <2 x i64>
%10 = xor <2 x i64> %9, <i64 -1, i64 -1>
%11 = and <2 x i64> %10, %2
%12 = and <2 x i64> %9, %3
%13 = or <2 x i64> %11, %12
ret <2 x i64> %13
}
Mind you, on X86 at least it doesn't affect final codegen:
cmp_i8_sel_v16i8:
vpcmpeqb %xmm1, %xmm0, %xmm0
vpblendvb %xmm0, %xmm3, %xmm2, %xmm0
retq
cmp_i8_sel_m128i:
vpcmpeqb %xmm1, %xmm0, %xmm0
vpblendvb %xmm0, %xmm3, %xmm2, %xmm0
retq
--
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/20170803/53d88fa7/attachment.html>
More information about the llvm-bugs
mailing list