[PATCH] Remove redundent register mov by improving TwoAddressInstructionPass
Wei Mi
wmi at google.com
Fri Feb 27 15:35:22 PST 2015
REPOSITORY
rL LLVM
================
Comment at: lib/CodeGen/TwoAddressInstructionPass.cpp:314-315
@@ -311,1 +313,4 @@
+// getSingleDef -- return the MachineInstr* if it is the single def of the Reg
+// in current BB.
+static MachineInstr* getSingleDef(unsigned Reg, MachineBasicBlock *BB,
----------------
chandlerc wrote:
> Please use our modern doxygen comment style for new code. (I know a bunch of old code doesn't)
>
> http://llvm.org/docs/CodingStandards.html#doxygen-use-in-documentation-comments
Fixed.
================
Comment at: lib/CodeGen/TwoAddressInstructionPass.cpp:340-341
@@ +339,4 @@
+ unsigned TmpReg = FromReg;
+ // We set Length to 3 for now, which covers the common cases we see. Set the
+ // Length limit is to avoid endless searching in a copy chain loop.
+ int Length = 3;
----------------
chandlerc wrote:
> It would be good to document your idea for how to handle this more generally in a FIXME here and maybe file a PR to track it?
FIXME added. File a PR here: http://llvm.org/bugs/show_bug.cgi?id=22689
================
Comment at: test/CodeGen/X86/twoaddr-coalesce-3.ll:22
@@ +21,3 @@
+; CHECK-LABEL: foo:
+; CHECK: [[LOOP1:.LBB0_[0-9]+]]: # %for.body
+; CHECK-NOT: mov
----------------
qcolombet wrote:
> Like I said, you shouldn’t use basic block labels, but rely on branch instruction on other block.
> E.g, on my machine the label looks like this: LBB0_…, i.e., no leading ‘.’.
>
> So, what I was saying was to use something like:
>
> ; End of the first block.
> CHECK: jp
> ; We enter the loop
> CHECK loop boby
> ; The loop body is done
> CHECK jp
Yes, I understand your concern. However using branch instruction in previous block as boundary will introduce extra code in loop preheader, including mov. Like the following movl total(%rip), ..., I can make the test right, but it introduces extra complexity.
jle .LBB0_4
# BB#1: # %for.body.lr.ph
xorl %edx, %edx
movl total(%rip), %ecx
.align 16, 0x90
.LBB0_2: # %for.body
# =>This Inner Loop Header: Depth=1
movl %edx, %esi
shrl $31, %esi
addl %edx, %esi
sarl %esi
addl %esi, %ecx
incl %edx
cmpl %eax, %edx
jl .LBB0_2
Do you like CHECK: [[LOOP:[.]?LBB0_[0-9]+]]; ? If not, I will follow your way to use last branch as the boundary.
http://reviews.llvm.org/D7806
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list