[PATCH] Remove redundent register mov by improving TwoAddressInstructionPass

Wei Mi wmi at google.com
Tue Feb 24 17:02:09 PST 2015


I rewrite the code to expand the cases that can be handled.

Now for %reg103 = ADD %reg102, %reg101;  I check whether there is a reversed copy chain from %reg102 to %reg103 or from %reg101 to %reg103. If there is a reversed copy chain from a src operand to a dest oeprand, that src operand will be choosen to be merged with the dest operand.  In this way, the case Quentin suggested like the following will be handled.

// %reg101 = MOV %reg100
// %reg102 = ...
// %reg103 = ADD %reg102, %reg101
// %reg104 = <something> %reg103
// %reg100 = MOV %reg103

I still don't use getUniqueVRegDef to replace getSingleDef because getSingleDef can find out the def inside current BB when a use has multiple defs (one in current BB and one in predecessor BB). This is common because the IR in TwoAddrInstruction pass is already out-of-ssa form. getUniqueVRegDef will return NULL for that case.

Thanks,
Wei.


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D7806

Files:
  lib/CodeGen/TwoAddressInstructionPass.cpp
  test/CodeGen/X86/twoaddr-coalesce-3.ll

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7806.20641.patch
Type: text/x-patch
Size: 5713 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150225/35e5b7b9/attachment.bin>


More information about the llvm-commits mailing list