[llvm-bugs] [Bug 34584] New: [AVX512] eliminate compare of bool mask for masked store
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Sep 12 15:58:45 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=34584
Bug ID: 34584
Summary: [AVX512] eliminate compare of bool mask for masked
store
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: spatel+llvm at rotateright.com
CC: llvm-bugs at lists.llvm.org
As discussed in D37446:
https://reviews.llvm.org/D37446
If we have a bool vector mask for a masked store, we shouldn't need to generate
a compare to set the sign bits of that mask.
declare void @llvm.masked.store.v4f32.p0v4f32(<4 x float>, <4 x float>*, i32,
<4 x i1>)
declare void @llvm.masked.store.v16f32.p0v16f32(<16 x float>, <16 x float>*,
i32, <16 x i1>)
define void @generic_masked_stores(<4 x float> %x, <4 x float>* %ptr, <4 x
float> %y, <4 x i32> %mask) {
%trunc = icmp slt <4 x i32> %mask, zeroinitializer
call void @llvm.masked.store.v4f32.p0v4f32(<4 x float> %x, <4 x float>* %ptr,
i32 1, <4 x i1> %trunc)
ret void
}
define void @generic_masked_stores_16(<16 x float> %x, <16 x float>* %ptr, <16
x float> %y, <16 x i32> %mask) {
%trunc = icmp slt <16 x i32> %mask, zeroinitializer
call void @llvm.masked.store.v16f32.p0v16f32(<16 x float> %x, <16 x float>*
%ptr, i32 1, <16 x i1> %trunc)
ret void
}
-----------------------------------------------------------------------------
$ ./llc -o - maskedstore_truncmask.ll -mattr=avx512f,avx512vl,avx512bw
_generic_masked_stores:
vpxor %xmm1, %xmm1, %xmm1
vpcmpgtd %xmm2, %xmm1, %k1
vmovups %xmm0, (%rdi) {%k1}
retq
_generic_masked_stores_16:
vpxor %xmm1, %xmm1, %xmm1
vpcmpgtd %zmm2, %zmm1, %k1
vmovups %zmm0, (%rdi) {%k1}
vzeroupper
retq
-----------------------------------------------------------------------------
A better option would be:
vpmovd2m %xmm2, %k1
vmovups %xmm0, (%rdi) {%k1}
Shorter, but not a universal solution for AVX512:
vmaskmovps %xmm0, %xmm2, (%rdi)
--
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/20170912/e10bb2c8/attachment.html>
More information about the llvm-bugs
mailing list