[llvm-commits] [llvm] r162777 - /llvm/trunk/lib/Target/Mips/MipsLongBranch.cpp

Akira Hatanaka ahatanaka at mips.com
Tue Aug 28 11:58:57 PDT 2012


Author: ahatanak
Date: Tue Aug 28 13:58:57 2012
New Revision: 162777

URL: http://llvm.org/viewvc/llvm-project?rev=162777&view=rev
Log:
Follow-up patch to r162731.

Fix a couple of bugs in mips' long branch pass.
This patch was supposed to be committed along with r162731, so I don't have a
new test case.


Modified:
    llvm/trunk/lib/Target/Mips/MipsLongBranch.cpp

Modified: llvm/trunk/lib/Target/Mips/MipsLongBranch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsLongBranch.cpp?rev=162777&r1=162776&r2=162777&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsLongBranch.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsLongBranch.cpp Tue Aug 28 13:58:57 2012
@@ -257,10 +257,10 @@
     LongBrMBB->addSuccessor(BalTgtMBB);
     BalTgtMBB->addSuccessor(TgtMBB);
 
-    uint64_t TgtAddress = MBBInfos[TgtMBB->getNumber()].Address;
-    uint64_t Offset = TgtAddress - (I.Address + I.Size - 20);
-    uint64_t Lo = Offset & 0xffff;
-    uint64_t Hi = ((Offset + 0x8000) >> 16) & 0xffff;
+    int64_t TgtAddress = MBBInfos[TgtMBB->getNumber()].Address;
+    int64_t Offset = TgtAddress - (I.Address + I.Size - 20);
+    int64_t Lo = SignExtend64<16>(Offset & 0xffff);
+    int64_t Hi = SignExtend64<16>(((Offset + 0x8000) >> 16) & 0xffff);
 
     if (ABI != MipsSubtarget::N64) {
       // $longbr:
@@ -317,8 +317,9 @@
       // $fallthrough:
       //
 
-      uint64_t Higher = ((Offset + 0x80008000) >> 32) & 0xffff;
-      uint64_t Highest = ((Offset + 0x800080008000LL) >> 48) & 0xffff;
+      int64_t Higher = SignExtend64<16>(((Offset + 0x80008000) >> 32) & 0xffff);
+      int64_t Highest =
+        SignExtend64<16>(((Offset + 0x800080008000LL) >> 48) & 0xffff);
 
       Pos = LongBrMBB->begin();
 
@@ -412,7 +413,7 @@
         continue;
 
       I->HasLongBranch = true;
-      I->Size += LongBranchSeqSize;
+      I->Size += LongBranchSeqSize * 4;
       ++LongBranches;
       EverMadeChange = MadeChange = true;
     }
@@ -427,7 +428,7 @@
 
     uint64_t Address = 0;
 
-    for (I = MBBInfos.begin(); I != E; ++I, Address += I->Size)
+    for (I = MBBInfos.begin(); I != E; Address += I->Size, ++I)
       I->Address = Address;
   }
 





More information about the llvm-commits mailing list