[PATCH] D20774: [InstCombine] look through bitcasts to find selects
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sat May 28 12:24:14 PDT 2016
spatel created this revision.
spatel added reviewers: majnemer, RKSimon, chandlerc.
spatel added a subscriber: llvm-commits.
Herald added a subscriber: mcrosier.
The motivating example for this patch is this IR produced via SSE intrinsics in C:
define <2 x i64> @gibson(<2 x i64> %a, <2 x i64> %b) {
%t0 = bitcast <2 x i64> %a to <4 x i32>
%t1 = bitcast <2 x i64> %b to <4 x i32>
%cmp = icmp sgt <4 x i32> %t0, %t1
%sext = sext <4 x i1> %cmp to <4 x i32>
%t2 = bitcast <4 x i32> %sext to <2 x i64>
%and = and <2 x i64> %t2, %a
%neg = xor <4 x i32> %sext, <i32 -1, i32 -1, i32 -1, i32 -1>
%neg2 = bitcast <4 x i32> %neg to <2 x i64>
%and2 = and <2 x i64> %neg2, %b
%or = or <2 x i64> %and, %and2
ret <2 x i64> %or
}
For an AVX target, this is currently:
vpcmpgtd %xmm1, %xmm0, %xmm2
vpand %xmm0, %xmm2, %xmm0
vpandn %xmm1, %xmm2, %xmm1
vpor %xmm1, %xmm0, %xmm0
retq
With this patch, it becomes:
vpmaxsd %xmm1, %xmm0, %xmm0
http://reviews.llvm.org/D20774
Files:
lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
test/Transforms/InstCombine/logical-select.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20774.58899.patch
Type: text/x-patch
Size: 6267 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160528/2bdab074/attachment.bin>
More information about the llvm-commits
mailing list