<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - [AVX512] eliminate compare of bool mask for masked store"
href="https://bugs.llvm.org/show_bug.cgi?id=34584">34584</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[AVX512] eliminate compare of bool mask for masked store
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>spatel+llvm@rotateright.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>As discussed in D37446:
<a href="https://reviews.llvm.org/D37446">https://reviews.llvm.org/D37446</a>
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)</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>