[llvm-commits] [llvm] r60076 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp

Chris Lattner sabre at nondot.org
Tue Nov 25 18:11:11 PST 2008


Author: lattner
Date: Tue Nov 25 20:11:11 2008
New Revision: 60076

URL: http://llvm.org/viewvc/llvm-project?rev=60076&view=rev
Log:
add a comment, make save/restore logic more obvious.

Modified:
    llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=60076&r1=60075&r2=60076&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Tue Nov 25 20:11:11 2008
@@ -864,22 +864,22 @@
   // Worse case, the target should support [reg] addressing modes. :)
   if (!AddrMode.HasBaseReg) {
     AddrMode.HasBaseReg = true;
+    AddrMode.BaseReg = Addr;
     // Still check for legality in case the target supports [imm] but not [i+r].
-    if (TLI.isLegalAddressingMode(AddrMode, AccessTy)) {
-      AddrMode.BaseReg = Addr;
+    if (TLI.isLegalAddressingMode(AddrMode, AccessTy))
       return true;
-    }
     AddrMode.HasBaseReg = false;
+    AddrMode.BaseReg = 0;
   }
 
   // If the base register is already taken, see if we can do [r+r].
   if (AddrMode.Scale == 0) {
     AddrMode.Scale = 1;
-    if (TLI.isLegalAddressingMode(AddrMode, AccessTy)) {
-      AddrMode.ScaledReg = Addr;
+    AddrMode.ScaledReg = Addr;
+    if (TLI.isLegalAddressingMode(AddrMode, AccessTy))
       return true;
-    }
     AddrMode.Scale = 0;
+    AddrMode.ScaledReg = 0;
   }
   // Couldn't match.
   return false;
@@ -954,7 +954,7 @@
 ///
 /// Note that this (like most of CodeGenPrepare) is just a rough heuristic.  If
 /// X was live across 'load Z' for other reasons, we actually *would* want to
-/// fold the addressing mode in the Z case.
+/// fold the addressing mode in the Z case.  This would make Y die earlier.
 bool AddressingModeMatcher::
 IsProfitableToFoldIntoAddressingMode(Instruction *I) {
   if (IgnoreProfitability || !ENABLECRAZYHACK) return true;





More information about the llvm-commits mailing list