diff options
| author | Devang Patel <dpatel@apple.com> | 2007-08-10 00:53:35 +0000 | 
|---|---|---|
| committer | Devang Patel <dpatel@apple.com> | 2007-08-10 00:53:35 +0000 | 
| commit | 7bdf4531bb7507584947d27bfd7fdfcdb69eb0ad (patch) | |
| tree | de77b670905f7bd4dce5eab93be1356a9f8b7c6e /llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp | |
| parent | 67af6cd7eaf7233966c1c91d0a3b9fd456f1f70d (diff) | |
| download | bcm5719-llvm-7bdf4531bb7507584947d27bfd7fdfcdb69eb0ad.tar.gz bcm5719-llvm-7bdf4531bb7507584947d27bfd7fdfcdb69eb0ad.zip | |
Calculate exit and start value of true loop and false loop respectively.
llvm-svn: 40978
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp | 30 | 
1 files changed, 28 insertions, 2 deletions
| diff --git a/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp b/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp index 887a730e623..8234317444a 100644 --- a/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp @@ -587,11 +587,37 @@ unsigned LoopIndexSplit::findSplitCost(Loop *L, SplitInfo &SD) {  }  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.  | 

