[llvm-bugs] [Bug 27827] New: partial redundent mov
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri May 20 13:04:25 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=27827
Bug ID: 27827
Summary: partial redundent mov
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Register Allocator
Assignee: unassignedbugs at nondot.org
Reporter: wmi at google.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
Created attachment 16390
--> https://llvm.org/bugs/attachment.cgi?id=16390&action=edit
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, http://reviews.llvm.org/D20315?id=57666
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.
--
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/20160520/7d355a5a/attachment.html>
More information about the llvm-bugs
mailing list