<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 - Poor code generation for masked scalar store"
href="https://bugs.llvm.org/show_bug.cgi?id=38986">38986</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Poor code generation for masked scalar 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>Linux
</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>listmail@philipreames.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>We allow the spelling of predicated scalar stores using the masked.load
intrinsic (by loading a <1 x Y> vector>), but the code generation for such is
terrible. The odd part is the terrible bits don't appear length specific.
$ cat masked-scalar.ll
declare <1 x i32> @llvm.masked.load.v1i32.p0v1i32 (<1 x i32>*, i32, <1 x i1>,
<1 x i32>)
define i32 @test(i1 %c, i32* %p) {
%vc = insertelement <1 x i1> undef, i1 %c, i32 0
%vp = bitcast i32* %p to <1 x i32>*
%L = call <1 x i32> @llvm.masked.load.v1i32.p0v1i32 (<1 x i32>* %vp, i32 4, <1
x i1> %vc, <1 x i32> undef)
%ret = bitcast <1 x i32> %L to i32
ret i32 %ret
}
define i32 @test2(i1 %c, i32* %p) {
br i1 %c, label %taken, label %untaken
taken:
%v = load i32, i32* %p
ret i32 %v
untaken:
ret i32 undef
}
$ ../build/bin/opt -O3 -S masked-scalar.ll | ../build/bin/llc -O3 -mcpu=skylake
.text
.file "masked-scalar.ll"
.globl test # -- Begin function test
.p2align 4, 0x90
.type test,@function
test: # @test
# %bb.0:
andb $1, %dil
movl %edi, %eax
negb %al
# implicit-def: $ecx
testb %dil, %dil
jne .LBB0_1
# %bb.2: # %else
testb $1, %al
cmovnel %ecx, %eax
retq
.LBB0_1: # %cond.load
movl (%rsi), %ecx
testb $1, %al
cmovnel %ecx, %eax
retq
.Lfunc_end0:
.size test, .Lfunc_end0-test
# -- End function
.globl test2 # -- Begin function test2
.p2align 4, 0x90
.type test2,@function
test2: # @test2
# %bb.0:
testb $1, %dil
# implicit-def: $eax
# implicit-def: $ax
# implicit-def: $al
# implicit-def: $ah
# implicit-def: $hax
je .LBB1_2
# %bb.1: # %taken
movl (%rsi), %eax
.LBB1_2: # %untaken
retq
.Lfunc_end1:
.size test2, .Lfunc_end1-test2
# -- End function
.section ".note.GNU-stack","",@progbits
Observations:
1) We should be able to use a simple test/je for the i1 vector test.
2) We don't need the cmovs at all since we're selecting with undef.</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>