OSDN Git Service

[RegisterBankInfo] Adapt the copy cost logic to give something sane by default.
authorQuentin Colombet <qcolombet@apple.com>
Wed, 8 Jun 2016 01:17:10 +0000 (01:17 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Wed, 8 Jun 2016 01:17:10 +0000 (01:17 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272085 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h

index cc2c80d..e9b2a06 100644 (file)
@@ -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