[llvm-commits] [llvm] r40978 - /llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp

Devang Patel dpatel at apple.com
Thu Aug 9 17:53:36 PDT 2007


Author: dpatel
Date: Thu Aug  9 19:53:35 2007
New Revision: 40978

URL: http://llvm.org/viewvc/llvm-project?rev=40978&view=rev
Log:
Calculate exit and start value of true loop and false loop respectively.

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

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

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Thu Aug  9 19:53:35 2007
@@ -587,11 +587,37 @@
 }
 
 bool LoopIndexSplit::splitLoop(SplitInfo &SD) {
+
+  BasicBlock *Preheader = L->getLoopPreheader();
+
   // True loop is original loop. False loop is cloned loop.
+
+  bool SignedPredicate = ExitCondition->isSignedPredicate();  
   //[*] Calculate True loop's new Exit Value in loop preheader.
-  //      NewExitValue = min(SplitValue, ExitValue)
+  //      TLExitValue = min(SplitValue, ExitValue)
   //[*] Calculate False loop's new Start Value in loop preheader.
-  //      NewStartValue = min(SplitValue, TrueLoop.StartValue)
+  //      FLStartValue = min(SplitValue, TrueLoop.StartValue)
+  Value *TLExitValue = NULL;
+  Value *FLStartValue = NULL;
+  if (isa<ConstantInt>(SD.SplitValue)) {
+    TLExitValue = SD.SplitValue;
+    FLStartValue = SD.SplitValue;
+  }
+  else {
+    Value *C1 = new ICmpInst(SignedPredicate ? 
+                            ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT,
+                            SD.SplitValue, ExitValue, "lsplit.ev",
+                            Preheader->getTerminator());
+    TLExitValue = new SelectInst(C1, SD.SplitValue, ExitValue, 
+                                 "lsplit.ev", Preheader->getTerminator());
+
+    Value *C2 = new ICmpInst(SignedPredicate ? 
+                             ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT,
+                             SD.SplitValue, StartValue, "lsplit.sv",
+                             Preheader->getTerminator());
+    FLStartValue = new SelectInst(C2, SD.SplitValue, StartValue,
+                                  "lsplit.sv", Preheader->getTerminator());
+  }
   //[*] Split Exit Edge.
   //[*] Clone loop. Avoid true destination of split condition and 
   //    the blocks dominated by true destination. 





More information about the llvm-commits mailing list