[PATCH] D46127: [RegisterCoalesing] Eliminate unnecessary live range shrinking inside of reMaterializeTrivialDef
Wei Mi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 26 09:03:54 PDT 2018
wmi created this revision.
wmi added reviewers: qcolombet, MatzeB.
For the following mir case below:
%2:gr32 = MOV32ri -343593632
$edx = COPY %2:gr32
TCRETURNdi64 @llvm_gcda_emit_function, 0
$edx = COPY %2:gr32
TCRETURNdi64 @llvm_gcda_emit_function, 0
...
During RegisterCoalescing, %edx = COPY %2:gr32 will be replaced by %edx = MOV32ri -343593632 in reMaterializeTrivialDef, and each time we do the replacement, shrinkUses will be called to shrink the live range of %2. shrinkUses is a relative high cost operation. If we have a lot of COPY to be eliminated in reMaterializeTrivialDef, we will see compile time problem. However, if we know there is other use of %2 after the current COPY instruction, we don't need to call shrinkUses because we know the live range of %2 is not going to change after the COPY is removed.
The patch will skip shrinkUses call when deleting a COPY instruction if the live range of %2 lives at the DeadSlot of the COPY instruction and the live range doesn't live at the end of current basicblock (to avoid the current COPY is the last use of %2 in a loop or cycle)
We saw in an extreme case that the file's compile time was reduced from 300s to 200s because of the patch.
Repository:
rL LLVM
https://reviews.llvm.org/D46127
Files:
lib/CodeGen/RegisterCoalescer.cpp
test/CodeGen/X86/only-necessary-shrink.mir
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46127.144130.patch
Type: text/x-patch
Size: 4079 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180426/d1f61544/attachment.bin>
More information about the llvm-commits
mailing list