[llvm] r272085 - [RegisterBankInfo] Adapt the copy cost logic to give something sane by default.

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 7 18:17:10 PDT 2016


Author: qcolombet
Date: Tue Jun  7 20:17:10 2016
New Revision: 272085

URL: http://llvm.org/viewvc/llvm-project?rev=272085&view=rev
Log:
[RegisterBankInfo] Adapt the copy cost logic to give something sane by default.

The generic implementation stated that all copies were free, which is
unlikely. Now, only the copies within the same register bank are free.
We assume they will get coalesced.

Modified:
    llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h

Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h?rev=272085&r1=272084&r2=272085&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h Tue Jun  7 20:17:10 2016
@@ -359,7 +359,11 @@ public:
   /// \note Since this is a copy, both registers have the same size.
   virtual unsigned copyCost(const RegisterBank &A, const RegisterBank &B,
                             unsigned Size) const {
-    return 0;
+    // Optimistically assume that copies are coalesced. I.e., when
+    // they are on the same bank, they are free.
+    // Otherwise assume a non-zero cost of 1. The targets are supposed
+    // to override that properly anyway if they care.
+    return &A != &B;
   }
 
   /// Identifier used when the related instruction mapping instance




More information about the llvm-commits mailing list