<html>
<head>
<base href="https://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 --- - partial redundent mov"
href="https://llvm.org/bugs/show_bug.cgi?id=27827">27827</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>partial redundent mov
</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>Register Allocator
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>wmi@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=16390" name="attach_16390" title="testcase 1.cc">attachment 16390</a> <a href="attachment.cgi?id=16390&action=edit" title="testcase 1.cc">[details]</a></span>
testcase 1.cc
Two testcases which may have the same problem:
For 1.cc, we saw the following code snippet in the generated code:
~/workarea/llvm-r270096/dbuild/bin/clang -O2 -S 1.cc -fno-omit-frame-pointer -o
1.s
.LBB0_43: # %if.end.i161
# in Loop: Header=BB0_8 Depth=1
movl %r14d, %ecx
subq %rcx, %r12
movl $64, %r8d
subl %r15d, %r8d
movq %rbx, %rdx
movl %r8d, %ecx
shrq %cl, %rdx
addq %r12, %rdx
movl %r15d, %ecx
shlq %cl, %rbx
jmp .LBB0_44
...
# BB#35: # %if.then.i123
# in Loop: Header=BB0_8 Depth=1
movl $4, %ecx
subl %r15d, %ecx
movq %r12, %rdx
shrq %cl, %rdx
movl %r15d, %ecx
shlq %cl, %r12
movq %r12, %rbx
.LBB0_44: # %if.end31.i165
# in Loop: Header=BB0_8 Depth=1
movq %rbx, %r12
For "movq %rbx, %r12" in .LBB0_44, if it is promoted to the end of its
predecessors BB#35 and LBB0_43, the copy promoted to BB#35 can be removed and
the execution path from BB#35 to .LBB0_44 is accelerated.
For 2.c, to reproduce the problem, <a href="http://reviews.llvm.org/D20315?id=57666">http://reviews.llvm.org/D20315?id=57666</a>
should be applied.
~/workarea/llvm-r270096-with-D20315/dbuild/bin/clang -O2 -S 2.c
# BB#0: # %entry
pxor %xmm0, %xmm0
movdqa .LCPI0_0(%rip), %xmm4 # xmm4 = [0,1,2,3]
movl $1000, %eax # imm = 0x3E8
movdqa .LCPI0_1(%rip), %xmm1 # xmm1 = [4,4,4,4]
movdqa .LCPI0_2(%rip), %xmm2 # xmm2 = [2,2,2,2]
pxor %xmm3, %xmm3
.p2align 4, 0x90
.LBB0_1: # %vector.body
# =>This Inner Loop Header: Depth=1
movdqa %xmm4, %xmm5
paddd %xmm1, %xmm5
pxor %xmm2, %xmm4
pshufd $78, %xmm4, %xmm6 # xmm6 = xmm4[2,3,0,1]
movdqa %xmm6, %xmm7
psrad $31, %xmm7
punpckldq %xmm7, %xmm6 # xmm6 =
xmm6[0],xmm7[0],xmm6[1],xmm7[1]
movdqa %xmm4, %xmm7
psrad $31, %xmm7
punpckldq %xmm7, %xmm4 # xmm4 =
xmm4[0],xmm7[0],xmm4[1],xmm7[1]
paddq %xmm4, %xmm0
paddq %xmm6, %xmm3
addl $-4, %eax
movdqa %xmm5, %xmm4
jne .LBB0_1
It is beneficial to mov "movdqa %xmm4, %xmm5" at the start of LBB0_1 to the
end of all its predecessors: the end of BB#0 and the end of LBB0_1.
# BB#0: # %entry
pxor %xmm0, %xmm0
movdqa .LCPI0_0(%rip), %xmm4 # xmm4 = [0,1,2,3]
movl $1000, %eax # imm = 0x3E8
movdqa .LCPI0_1(%rip), %xmm1 # xmm1 = [4,4,4,4]
movdqa .LCPI0_2(%rip), %xmm2 # xmm2 = [2,2,2,2]
pxor %xmm3, %xmm3
movdqa %xmm4, %xmm5 ==> promoted to preheader
.p2align 4, 0x90
.LBB0_1: # %vector.body
# =>This Inner Loop Header: Depth=1
paddd %xmm1, %xmm5
pxor %xmm2, %xmm4
pshufd $78, %xmm4, %xmm6 # xmm6 = xmm4[2,3,0,1]
movdqa %xmm6, %xmm7
psrad $31, %xmm7
punpckldq %xmm7, %xmm6 # xmm6 =
xmm6[0],xmm7[0],xmm6[1],xmm7[1]
movdqa %xmm4, %xmm7
psrad $31, %xmm7
punpckldq %xmm7, %xmm4 # xmm4 =
xmm4[0],xmm7[0],xmm4[1],xmm7[1]
paddq %xmm4, %xmm0
paddq %xmm6, %xmm3
addl $-4, %eax
movdqa %xmm5, %xmm4
movdqa %xmm4, %xmm5 ==> apparently redundent and will be deleted.
jne .LBB0_1
I think register coalescer can be improved to remove such partial redundent
mov.</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>