[llvm-bugs] [Bug 26701] New: [x86, SSE] missing optimizations for pos/neg integer vector comparisons
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Feb 22 13:12:12 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=26701
Bug ID: 26701
Summary: [x86, SSE] missing optimizations for pos/neg integer
vector comparisons
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: spatel+llvm at rotateright.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
Checking if integer vector elements are positive or negative would seem to be a
common operation, but we don't handle this very well. We need to do extra work
because SSE/AVX only provide 2 integer comparison instructions (eq/gt):
define <4 x i32> @is_positive_using_signshift(<4 x i32> %x) {
%sign = ashr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
%not = xor <4 x i32> %sign, <i32 -1, i32 -1, i32 -1, i32 -1>
ret <4 x i32> %not
}
define <4 x i32> @is_positive_using_sge(<4 x i32> %x) {
%cmp = icmp sge <4 x i32> %x, zeroinitializer
%sext = sext <4 x i1> %cmp to <4 x i32>
ret <4 x i32> %sext
}
define <4 x i32> @is_positive_using_sgt(<4 x i32> %x) {
%cmp = icmp sgt <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
%sext = sext <4 x i1> %cmp to <4 x i32>
ret <4 x i32> %sext
}
define <4 x i32> @is_negative_using_signshift(<4 x i32> %x) {
%sign = ashr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
ret <4 x i32> %sign
}
define <4 x i32> @is_negative_using_slt(<4 x i32> %x) {
%cmp = icmp slt <4 x i32> %x, zeroinitializer
%sext = sext <4 x i1> %cmp to <4 x i32>
ret <4 x i32> %sext
}
define <4 x i32> @is_negative_using_sle(<4 x i32> %x) {
%cmp = icmp sle <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
%sext = sext <4 x i1> %cmp to <4 x i32>
ret <4 x i32> %sext
}
$ ./llc -o - pcmp.ll -mattr=avx
_is_positive_using_signshift:
vpsrad $31, %xmm0, %xmm0
vpcmpeqd %xmm1, %xmm1, %xmm1
vpxor %xmm1, %xmm0, %xmm0
retq
_is_positive_using_sge:
vpxor %xmm1, %xmm1, %xmm1
vpcmpgtd %xmm0, %xmm1, %xmm0
vpcmpeqd %xmm1, %xmm1, %xmm1
vpxor %xmm1, %xmm0, %xmm0
retq
_is_positive_using_sgt:
vpcmpeqd %xmm1, %xmm1, %xmm1
vpcmpgtd %xmm1, %xmm0, %xmm0
retq
_is_negative_using_signshift:
vpsrad $31, %xmm0, %xmm0
retq
_is_negative_using_slt:
vpxor %xmm1, %xmm1, %xmm1
vpcmpgtd %xmm0, %xmm1, %xmm0
retq
_is_negative_using_sle:
vpcmpeqd %xmm1, %xmm1, %xmm1
vpcmpgtd %xmm1, %xmm0, %xmm0
vpxor %xmm1, %xmm0, %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/20160222/8c6a6170/attachment.html>
More information about the llvm-bugs
mailing list