> I think that the test for virtual registers is more strict than it needs to be,<br>> it should be possible to coalesce two virtual registers the class of one<br>> is a subclass of the other.<br><br><div>That certainly sounds safe if the destination class is a subclass of the source class. I assume going the other way is dangerous, in that it could leave junk in the non-aliased portion of the super-register?</div>
<div><br></div><div>Cheers,</div><div>Lang.</div><div><br><div class="gmail_quote">On Mon, Jul 12, 2010 at 11:45 AM, Rafael Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Author: rafael<br>
Date: Sun Jul 11 20:45:38 2010<br>
New Revision: 108118<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=108118&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=108118&view=rev</a><br>
Log:<br>
Don't use getPhysicalRegisterRegClass in PBQP. The existing checks that the<br>
physical register can be allocated in the class of the virtual are sufficient.<br>
<br>
I think that the test for virtual registers is more strict than it needs to be,<br>
it should be possible to coalesce two virtual registers the class of one<br>
is a subclass of the other.<br>
<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp<br>
<br>
Modified: llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp?rev=108118&r1=108117&r2=108118&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp?rev=108118&r1=108117&r2=108118&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp Sun Jul 11 20:45:38 2010<br>
@@ -396,28 +396,23 @@<br>
       if (srcRegIsPhysical && dstRegIsPhysical)<br>
         continue;<br>
<br>
-      // If it's a copy that includes a virtual register but the source and<br>
-      // destination classes differ then we can't coalesce, so continue with<br>
-      // the next instruction.<br>
-      const TargetRegisterClass *srcRegClass = srcRegIsPhysical ?<br>
-          tri->getPhysicalRegisterRegClass(srcReg) : mri->getRegClass(srcReg);<br>
-<br>
-      const TargetRegisterClass *dstRegClass = dstRegIsPhysical ?<br>
-          tri->getPhysicalRegisterRegClass(dstReg) : mri->getRegClass(dstReg);<br>
-<br>
-      if (srcRegClass != dstRegClass)<br>
+      // If it's a copy that includes two virtual register but the source and<br>
+      // destination classes differ then we can't coalesce.<br>
+      if (!srcRegIsPhysical && !dstRegIsPhysical &&<br>
+          mri->getRegClass(srcReg) != mri->getRegClass(dstReg))<br>
         continue;<br>
<br>
-      // We also need any physical regs to be allocable, coalescing with<br>
-      // a non-allocable register is invalid.<br>
-      if (srcRegIsPhysical) {<br>
+      // If one is physical and one is virtual, check that the physical is<br>
+      // allocatable in the class of the virtual.<br>
+      if (srcRegIsPhysical && !dstRegIsPhysical) {<br>
+        const TargetRegisterClass *dstRegClass = mri->getRegClass(dstReg);<br>
         if (std::find(dstRegClass->allocation_order_begin(*mf),<br>
                       dstRegClass->allocation_order_end(*mf), srcReg) ==<br>
             dstRegClass->allocation_order_end(*mf))<br>
           continue;<br>
       }<br>
-<br>
-      if (dstRegIsPhysical) {<br>
+      if (!srcRegIsPhysical && dstRegIsPhysical) {<br>
+        const TargetRegisterClass *srcRegClass = mri->getRegClass(srcReg);<br>
         if (std::find(srcRegClass->allocation_order_begin(*mf),<br>
                       srcRegClass->allocation_order_end(*mf), dstReg) ==<br>
             srcRegClass->allocation_order_end(*mf))<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>