<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - generate a vector load for a non-zero vector store of constants?"
href="http://llvm.org/bugs/show_bug.cgi?id=21990">21990</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>generate a vector load for a non-zero vector store of constants?
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Common Code Generator Code
</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>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Spinning this off from <a class="bz_bug_link
bz_status_NEW "
title="NEW --- - [X86][AVX] separate stores are not being merged into a single 256bit store."
href="show_bug.cgi?id=21711#c6">bug 21711, comment 6</a>:
$ cat store_non_zero_constants.ll
define void @merge_const_store_vec(i32* %p) {
%p0 = getelementptr inbounds i32* %p, i64 0
%p1 = getelementptr inbounds i32* %p, i64 1
%p2 = getelementptr inbounds i32* %p, i64 2
%p3 = getelementptr inbounds i32* %p, i64 3
%p4 = getelementptr inbounds i32* %p, i64 4
%p5 = getelementptr inbounds i32* %p, i64 5
%p6 = getelementptr inbounds i32* %p, i64 6
%p7 = getelementptr inbounds i32* %p, i64 7
store i32 0, i32* %p0, align 4
store i32 1, i32* %p1, align 4
store i32 2, i32* %p2, align 4
store i32 3, i32* %p3, align 4
store i32 4, i32* %p4, align 4
store i32 5, i32* %p5, align 4
store i32 6, i32* %p6, align 4
store i32 7, i32* %p7, align 4
ret void
}
Currently (r224581), we do not attempt to merge stores of non-zero constants
beyond the largest scalar store size. Presumably, this is to avoid generating a
vector load of those constants rather than materializing them in registers as
immediates.
So for an x86 AVX machine we generate:
0000 movabsq $0x100000000, %rax ## imm = 0x100000000
000a movq %rax, (%rdi)
000d movabsq $0x300000002, %rax ## imm = 0x300000002
0017 movq %rax, 0x8(%rdi)
001b movabsq $0x500000004, %rax ## imm = 0x500000004
0025 movq %rax, 0x10(%rdi)
0029 movabsq $0x700000006, %rax ## imm = 0x700000006
0033 movq %rax, 0x18(%rdi)
0037 retq
That's 55 bytes of instructions before the 'ret'. If we merged all those
constants and loaded them from memory instead, we'd have something like this:
0000 vmovdqu LCP_0(rip), %ymm0
0005 vmovdqu %ymm0, (%rdi)
000a retq
Trade-offs:
1. Add 32 bytes of constant pool data memory.
2. Subtract ~45 bytes of instruction memory.
3. Add a load instruction.
4. Remove 3 store instructions and 4 load immediates.
Is it worth generating a load to have a net savings in memory usage?</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>