[PATCH] D30751: [MachineCopyForwarding] Add new pass to do register COPY forwarding at end of register allocation.

Geoff Berry via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 8 11:38:10 PST 2017


gberry added a comment.

In https://reviews.llvm.org/D30751#695783, @hfinkel wrote:

> High-level question: Why does the register allocator not do this on its own?


I'm not sure I can fully answer that question, but doing this during register allocation could have the down-side of extending live ranges resulting in a worse allocation.  Doing it in a pass just after register allocation allows it to be more conservative/opportunistic and not impact e.g. the amount of spilling.

If instead you're asking, why not just append this code at the end of register allocation, the only reason is based on previous feedback from Quentin that this should be a separate pass.



================
Comment at: test/CodeGen/PowerPC/fma-mutate.ll:17
 ; CHECK: @foo3
-; CHECK: xsnmsubadp [[REG:[0-9]+]], {{[0-9]+}}, [[REG]]
+; CHECK: fmr [[REG:[0-9]+]], [[REG2:[0-9]+]]
+; CHECK: xsnmsubadp [[REG]], {{[0-9]+}}, [[REG2]]
----------------
hfinkel wrote:
> Is this an improvement?
The fmr is not new, I just added it to get the second register number.  Here are the full diffs before/after this change for this test:


```
 	fmr 3, 1
 	addi 3, 3, .LCPI0_0 at toc@l
 	lfs 2, 0(3)
-	xsnmsubadp 3, 2, 3
+	xsnmsubadp 3, 2, 1
 	xsmuldp 4, 0, 0
 	xsmaddmdp 4, 3, 2
 	xsmuldp 0, 0, 4
```



https://reviews.llvm.org/D30751





More information about the llvm-commits mailing list