<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 20, 2015, at 10:38 PM, Chandler Carruth <<a href="mailto:chandlerc@google.com" class="">chandlerc@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">If they cover the same different use cases, most notably the *specific* reason for using a percentage based threshold, that's what I was looking for.<br class=""></div></div></blockquote><div>Hi Chandler,</div><div><br class=""></div>It is basically a single test, but it’s invoked with 4 different sets of thresholds:</div><div>1) Check that we unroll smallest loops (size < unroll-threshold) independently on the new heuristics - it’s basically a loop that we’d unroll even without the heuristic.</div><div>2) Check that we don’t unroll huge loops (size > absolute-unroll-threshold).</div><div>3) Check that we unroll mid-sized loops (unroll-threshold < size < absolute-unroll-threshold) for which we predict a certain part of instructions to be removed (percentage of predicted-to-be-removed instructions > min-percent-to-unroll).</div><div><div>4) Check that we don’t unroll mid-sized loops (unroll-threshold < size < absolute-unroll-threshold) for which we predict less than a certain part of instructions to be removed (percentage of predicted-to-be-removed instructions < min-percent-to-unroll).</div><div><br class=""></div><div>Is it what you were looking for?</div><div><br class=""></div><div>Thanks,</div><div>Michael</div></div><div><br class=""><blockquote type="cite" class=""><div class=""><br class=""><div class="gmail_quote">On Thu, May 14, 2015 at 5:16 PM Michael Zolotukhin <<a href="mailto:mzolotukhin@apple.com" class="">mzolotukhin@apple.com</a>> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Chandler,<br class="">
<br class="">
We agreed that I’ll follow-up on this with adding examples from our discussion as tests. However, the original tests (test/Transforms/LoopUnroll/full-unroll-heuristics.ll) are essentially covering the same cases. Did you mean some other tests, or these are sufficient?<br class="">
<br class="">
Thanks,<br class="">
Michael<br class="">
<br class="">
> On May 12, 2015, at 10:20 AM, Michael Zolotukhin <<a href="mailto:mzolotukhin@apple.com" target="_blank" class="">mzolotukhin@apple.com</a>> wrote:<br class="">
><br class="">
> Author: mzolotukhin<br class="">
> Date: Tue May 12 12:20:03 2015<br class="">
> New Revision: 237156<br class="">
><br class="">
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D237156-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=6UzI8VuZg4hVPZsdf6eMAODupqaq32_-5DO7Jh3KQXY&s=UbPr-j1FyaJCVVoBBjDdrBSPX_TDESDmxwrssahOFjE&e=" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=237156&view=rev</a><br class="">
> Log:<br class="">
> Reimplement heuristic for estimating complete-unroll optimization effects.<br class="">
><br class="">
> Summary:<br class="">
> This patch reimplements heuristic that tries to estimate optimization beneftis<br class="">
> from complete loop unrolling.<br class="">
><br class="">
> In this patch I kept the minimal changes - e.g. I removed code handling<br class="">
> branches and folding compares. That's a promising area, but now there<br class="">
> are too many questions to discuss before we can enable it.<br class="">
><br class="">
> Test Plan: Tests are included in the patch.<br class="">
><br class="">
> Reviewers: hfinkel, chandlerc<br class="">
><br class="">
> Subscribers: llvm-commits<br class="">
><br class="">
> Differential Revision: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D8816&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=6UzI8VuZg4hVPZsdf6eMAODupqaq32_-5DO7Jh3KQXY&s=Q9ykJHWRNQEgqquxUUlsAgXgayGfU8IyrJfADMpaDdE&e=" target="_blank" class="">http://reviews.llvm.org/D8816</a><br class="">
><br class="">
> Added:<br class="">
>    llvm/trunk/test/Transforms/LoopUnroll/full-unroll-bad-geps.ll<br class="">
> Modified:<br class="">
>    llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp<br class="">
>    llvm/trunk/test/Transforms/LoopUnroll/full-unroll-heuristics.ll<br class="">
><br class="">
> Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp<br class="">
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_Transforms_Scalar_LoopUnrollPass.cpp-3Frev-3D237156-26r1-3D237155-26r2-3D237156-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=6UzI8VuZg4hVPZsdf6eMAODupqaq32_-5DO7Jh3KQXY&s=hej0KbCSXwBSj7bjjIUkz40-zVCRBO8jbrFCJRz4GFs&e=" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp?rev=237156&r1=237155&r2=237156&view=diff</a><br class="">
> ==============================================================================<br class="">
> --- llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp (original)<br class="">
> +++ llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp Tue May 12 12:20:03 2015<br class="">
> @@ -186,33 +186,21 @@ namespace {<br class="">
>     void selectThresholds(const Loop *L, bool HasPragma,<br class="">
>                           const TargetTransformInfo::UnrollingPreferences &UP,<br class="">
>                           unsigned &Threshold, unsigned &PartialThreshold,<br class="">
> -                          unsigned NumberOfOptimizedInstructions) {<br class="">
> +                          unsigned &AbsoluteThreshold,<br class="">
> +                          unsigned &PercentOfOptimizedForCompleteUnroll) {<br class="">
>       // Determine the current unrolling threshold.  While this is<br class="">
>       // normally set from UnrollThreshold, it is overridden to a<br class="">
>       // smaller value if the current function is marked as<br class="">
>       // optimize-for-size, and the unroll threshold was not user<br class="">
>       // specified.<br class="">
>       Threshold = UserThreshold ? CurrentThreshold : UP.Threshold;<br class="">
> -<br class="">
> -      // If we are allowed to completely unroll if we can remove M% of<br class="">
> -      // instructions, and we know that with complete unrolling we'll be able<br class="">
> -      // to kill N instructions, then we can afford to completely unroll loops<br class="">
> -      // with unrolled size up to N*100/M.<br class="">
> -      // Adjust the threshold according to that:<br class="">
> -      unsigned PercentOfOptimizedForCompleteUnroll =<br class="">
> -          UserPercentOfOptimized ? CurrentMinPercentOfOptimized<br class="">
> -                                 : UP.MinPercentOfOptimized;<br class="">
> -      unsigned AbsoluteThreshold = UserAbsoluteThreshold<br class="">
> -                                       ? CurrentAbsoluteThreshold<br class="">
> -                                       : UP.AbsoluteThreshold;<br class="">
> -      if (PercentOfOptimizedForCompleteUnroll)<br class="">
> -        Threshold = std::max<unsigned>(Threshold,<br class="">
> -                                       NumberOfOptimizedInstructions * 100 /<br class="">
> -                                           PercentOfOptimizedForCompleteUnroll);<br class="">
> -      // But don't allow unrolling loops bigger than absolute threshold.<br class="">
> -      Threshold = std::min<unsigned>(Threshold, AbsoluteThreshold);<br class="">
> -<br class="">
>       PartialThreshold = UserThreshold ? CurrentThreshold : UP.PartialThreshold;<br class="">
> +      AbsoluteThreshold = UserAbsoluteThreshold ? CurrentAbsoluteThreshold<br class="">
> +                                                : UP.AbsoluteThreshold;<br class="">
> +      PercentOfOptimizedForCompleteUnroll = UserPercentOfOptimized<br class="">
> +                                                ? CurrentMinPercentOfOptimized<br class="">
> +                                                : UP.MinPercentOfOptimized;<br class="">
> +<br class="">
>       if (!UserThreshold &&<br class="">
>           L->getHeader()->getParent()->hasFnAttribute(<br class="">
>               Attribute::OptimizeForSize)) {<br class="">
> @@ -231,6 +219,10 @@ namespace {<br class="">
>               std::max<unsigned>(PartialThreshold, PragmaUnrollThreshold);<br class="">
>       }<br class="">
>     }<br class="">
> +    bool canUnrollCompletely(Loop *L, unsigned Threshold,<br class="">
> +                             unsigned AbsoluteThreshold, uint64_t UnrolledSize,<br class="">
> +                             unsigned NumberOfOptimizedInstructions,<br class="">
> +                             unsigned PercentOfOptimizedForCompleteUnroll);<br class="">
>   };<br class="">
> }<br class="">
><br class="">
> @@ -253,57 +245,75 @@ Pass *llvm::createSimpleLoopUnrollPass()<br class="">
>   return llvm::createLoopUnrollPass(-1, -1, 0, 0);<br class="">
> }<br class="">
><br class="">
> -static bool isLoadFromConstantInitializer(Value *V) {<br class="">
> -  if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V))<br class="">
> -    if (GV->isConstant() && GV->hasDefinitiveInitializer())<br class="">
> -      return GV->getInitializer();<br class="">
> -  return false;<br class="">
> -}<br class="">
> -<br class="">
> namespace {<br class="">
> +/// \brief SCEV expressions visitor used for finding expressions that would<br class="">
> +/// become constants if the loop L is unrolled.<br class="">
> struct FindConstantPointers {<br class="">
> -  bool LoadCanBeConstantFolded;<br class="">
> +  /// \brief Shows whether the expression is ConstAddress+Constant or not.<br class="">
>   bool IndexIsConstant;<br class="">
> -  APInt Step;<br class="">
> -  APInt StartValue;<br class="">
> +<br class="">
> +  /// \brief Used for filtering out SCEV expressions with two or more AddRec<br class="">
> +  /// subexpressions.<br class="">
> +  ///<br class="">
> +  /// Used to filter out complicated SCEV expressions, having several AddRec<br class="">
> +  /// sub-expressions. We don't handle them, because unrolling one loop<br class="">
> +  /// would help to replace only one of these inductions with a constant, and<br class="">
> +  /// consequently, the expression would remain non-constant.<br class="">
> +  bool HaveSeenAR;<br class="">
> +<br class="">
> +  /// \brief If the SCEV expression becomes ConstAddress+Constant, this value<br class="">
> +  /// holds ConstAddress. Otherwise, it's nullptr.<br class="">
>   Value *BaseAddress;<br class="">
> +<br class="">
> +  /// \brief The loop, which we try to completely unroll.<br class="">
>   const Loop *L;<br class="">
> +<br class="">
>   ScalarEvolution &SE;<br class="">
> -  FindConstantPointers(const Loop *loop, ScalarEvolution &SE)<br class="">
> -      : LoadCanBeConstantFolded(true), IndexIsConstant(true), L(loop), SE(SE) {}<br class="">
><br class="">
> +  FindConstantPointers(const Loop *L, ScalarEvolution &SE)<br class="">
> +      : IndexIsConstant(true), HaveSeenAR(false), BaseAddress(nullptr),<br class="">
> +        L(L), SE(SE) {}<br class="">
> +<br class="">
> +  /// Examine the given expression S and figure out, if it can be a part of an<br class="">
> +  /// expression, that could become a constant after the loop is unrolled.<br class="">
> +  /// The routine sets IndexIsConstant and HaveSeenAR according to the analysis<br class="">
> +  /// results.<br class="">
> +  /// \returns true if we need to examine subexpressions, and false otherwise.<br class="">
>   bool follow(const SCEV *S) {<br class="">
>     if (const SCEVUnknown *SC = dyn_cast<SCEVUnknown>(S)) {<br class="">
>       // We've reached the leaf node of SCEV, it's most probably just a<br class="">
> -      // variable. Now it's time to see if it corresponds to a global constant<br class="">
> -      // global (in which case we can eliminate the load), or not.<br class="">
> +      // variable.<br class="">
> +      // If it's the only one SCEV-subexpression, then it might be a base<br class="">
> +      // address of an index expression.<br class="">
> +      // If we've already recorded base address, then just give up on this SCEV<br class="">
> +      // - it's too complicated.<br class="">
> +      if (BaseAddress) {<br class="">
> +        IndexIsConstant = false;<br class="">
> +        return false;<br class="">
> +      }<br class="">
>       BaseAddress = SC->getValue();<br class="">
> -      LoadCanBeConstantFolded =<br class="">
> -          IndexIsConstant && isLoadFromConstantInitializer(BaseAddress);<br class="">
>       return false;<br class="">
>     }<br class="">
>     if (isa<SCEVConstant>(S))<br class="">
> -      return true;<br class="">
> +      return false;<br class="">
>     if (const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(S)) {<br class="">
>       // If the current SCEV expression is AddRec, and its loop isn't the loop<br class="">
>       // we are about to unroll, then we won't get a constant address after<br class="">
>       // unrolling, and thus, won't be able to eliminate the load.<br class="">
> -      if (AR->getLoop() != L)<br class="">
> -        return IndexIsConstant = false;<br class="">
> -      // If the step isn't constant, we won't get constant addresses in unrolled<br class="">
> -      // version. Bail out.<br class="">
> -      if (const SCEVConstant *StepSE =<br class="">
> -              dyn_cast<SCEVConstant>(AR->getStepRecurrence(SE)))<br class="">
> -        Step = StepSE->getValue()->getValue();<br class="">
> -      else<br class="">
> -        return IndexIsConstant = false;<br class="">
> -<br class="">
> -      return IndexIsConstant;<br class="">
> +      if (AR->getLoop() != L) {<br class="">
> +        IndexIsConstant = false;<br class="">
> +        return false;<br class="">
> +      }<br class="">
> +      // We don't handle multiple AddRecs here, so give up in this case.<br class="">
> +      if (HaveSeenAR) {<br class="">
> +        IndexIsConstant = false;<br class="">
> +        return false;<br class="">
> +      }<br class="">
> +      HaveSeenAR = true;<br class="">
>     }<br class="">
> -    // If Result is true, continue traversal.<br class="">
> -    // Otherwise, we have found something that prevents us from (possible) load<br class="">
> -    // elimination.<br class="">
> -    return IndexIsConstant;<br class="">
> +<br class="">
> +    // Continue traversal.<br class="">
> +    return true;<br class="">
>   }<br class="">
>   bool isDone() const { return !IndexIsConstant; }<br class="">
> };<br class="">
> @@ -328,27 +338,54 @@ class UnrollAnalyzer : public InstVisito<br class="">
>   typedef InstVisitor<UnrollAnalyzer, bool> Base;<br class="">
>   friend class InstVisitor<UnrollAnalyzer, bool>;<br class="">
><br class="">
> +  struct SCEVGEPDescriptor {<br class="">
> +    Value *BaseAddr;<br class="">
> +    APInt Start;<br class="">
> +    APInt Step;<br class="">
> +  };<br class="">
> +<br class="">
> +  /// \brief The loop we're going to analyze.<br class="">
>   const Loop *L;<br class="">
> +<br class="">
> +  /// \brief TripCount of the given loop.<br class="">
>   unsigned TripCount;<br class="">
> +<br class="">
>   ScalarEvolution &SE;<br class="">
> +<br class="">
>   const TargetTransformInfo &TTI;<br class="">
><br class="">
> +  // While we walk the loop instructions, we we build up and maintain a mapping<br class="">
> +  // of simplified values specific to this iteration.  The idea is to propagate<br class="">
> +  // any special information we have about loads that can be replaced with<br class="">
> +  // constants after complete unrolling, and account for likely simplifications<br class="">
> +  // post-unrolling.<br class="">
>   DenseMap<Value *, Constant *> SimplifiedValues;<br class="">
> -  DenseMap<LoadInst *, Value *> LoadBaseAddresses;<br class="">
> -  SmallPtrSet<Instruction *, 32> CountedInstructions;<br class="">
><br class="">
> -  /// \brief Count the number of optimized instructions.<br class="">
> -  unsigned NumberOfOptimizedInstructions;<br class="">
> +  // To avoid requesting SCEV info on every iteration, request it once, and<br class="">
> +  // for each value that would become ConstAddress+Constant after loop<br class="">
> +  // unrolling, save the corresponding data.<br class="">
> +  SmallDenseMap<Value *, SCEVGEPDescriptor> SCEVCache;<br class="">
> +<br class="">
> +  /// \brief Number of currently simulated iteration.<br class="">
> +  ///<br class="">
> +  /// If an expression is ConstAddress+Constant, then the Constant is<br class="">
> +  /// Start + Iteration*Step, where Start and Step could be obtained from<br class="">
> +  /// SCEVCache.<br class="">
> +  unsigned Iteration;<br class="">
> +<br class="">
> +  /// \brief Upper threshold for complete unrolling.<br class="">
> +  unsigned MaxUnrolledLoopSize;<br class="">
><br class="">
> -  // Provide base case for our instruction visit.<br class="">
> +  /// Base case for the instruction visitor.<br class="">
>   bool visitInstruction(Instruction &I) { return false; };<br class="">
> -  // TODO: We should also visit ICmp, FCmp, GetElementPtr, Trunc, ZExt, SExt,<br class="">
> -  // FPTrunc, FPExt, FPToUI, FPToSI, UIToFP, SIToFP, BitCast, Select,<br class="">
> -  // ExtractElement, InsertElement, ShuffleVector, ExtractValue, InsertValue.<br class="">
> -  //<br class="">
> -  // Probaly it's worth to hoist the code for estimating the simplifications<br class="">
> -  // effects to a separate class, since we have a very similar code in<br class="">
> -  // InlineCost already.<br class="">
> +<br class="">
> +  /// TODO: Add visitors for other instruction types, e.g. ZExt, SExt.<br class="">
> +<br class="">
> +  /// Try to simplify binary operator I.<br class="">
> +  ///<br class="">
> +  /// TODO: Probaly it's worth to hoist the code for estimating the<br class="">
> +  /// simplifications effects to a separate class, since we have a very similar<br class="">
> +  /// code in InlineCost already.<br class="">
>   bool visitBinaryOperator(BinaryOperator &I) {<br class="">
>     Value *LHS = I.getOperand(0), *RHS = I.getOperand(1);<br class="">
>     if (!isa<Constant>(LHS))<br class="">
> @@ -365,7 +402,7 @@ class UnrollAnalyzer : public InstVisito<br class="">
>     else<br class="">
>       SimpleV = SimplifyBinOp(I.getOpcode(), LHS, RHS, DL);<br class="">
><br class="">
> -    if (SimpleV && CountedInstructions.insert(&I).second)<br class="">
> +    if (SimpleV)<br class="">
>       NumberOfOptimizedInstructions += TTI.getUserCost(&I);<br class="">
><br class="">
>     if (Constant *C = dyn_cast_or_null<Constant>(SimpleV)) {<br class="">
> @@ -375,207 +412,172 @@ class UnrollAnalyzer : public InstVisito<br class="">
>     return false;<br class="">
>   }<br class="">
><br class="">
> -  Constant *computeLoadValue(LoadInst *LI, unsigned Iteration) {<br class="">
> -    if (!LI)<br class="">
> -      return nullptr;<br class="">
> -    Value *BaseAddr = LoadBaseAddresses[LI];<br class="">
> -    if (!BaseAddr)<br class="">
> -      return nullptr;<br class="">
> -<br class="">
> -    auto GV = dyn_cast<GlobalVariable>(BaseAddr);<br class="">
> -    if (!GV)<br class="">
> -      return nullptr;<br class="">
> +  /// Try to fold load I.<br class="">
> +  bool visitLoad(LoadInst &I) {<br class="">
> +    Value *AddrOp = I.getPointerOperand();<br class="">
> +    if (!isa<Constant>(AddrOp))<br class="">
> +      if (Constant *SimplifiedAddrOp = SimplifiedValues.lookup(AddrOp))<br class="">
> +        AddrOp = SimplifiedAddrOp;<br class="">
> +<br class="">
> +    auto It = SCEVCache.find(AddrOp);<br class="">
> +    if (It == SCEVCache.end())<br class="">
> +      return false;<br class="">
> +    SCEVGEPDescriptor GEPDesc = It->second;<br class="">
> +<br class="">
> +    auto GV = dyn_cast<GlobalVariable>(GEPDesc.BaseAddr);<br class="">
> +    // We're only interested in loads that can be completely folded to a<br class="">
> +    // constant.<br class="">
> +    if (!GV || !GV->hasInitializer())<br class="">
> +      return false;<br class="">
><br class="">
>     ConstantDataSequential *CDS =<br class="">
>         dyn_cast<ConstantDataSequential>(GV->getInitializer());<br class="">
>     if (!CDS)<br class="">
> -      return nullptr;<br class="">
> -<br class="">
> -    const SCEV *BaseAddrSE = SE.getSCEV(BaseAddr);<br class="">
> -    const SCEV *S = SE.getSCEV(LI->getPointerOperand());<br class="">
> -    const SCEV *OffSE = SE.getMinusSCEV(S, BaseAddrSE);<br class="">
> -<br class="">
> -    APInt StepC, StartC;<br class="">
> -    const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(OffSE);<br class="">
> -    if (!AR)<br class="">
> -      return nullptr;<br class="">
> -<br class="">
> -    if (const SCEVConstant *StepSE =<br class="">
> -            dyn_cast<SCEVConstant>(AR->getStepRecurrence(SE)))<br class="">
> -      StepC = StepSE->getValue()->getValue();<br class="">
> -    else<br class="">
> -      return nullptr;<br class="">
> -<br class="">
> -    if (const SCEVConstant *StartSE = dyn_cast<SCEVConstant>(AR->getStart()))<br class="">
> -      StartC = StartSE->getValue()->getValue();<br class="">
> -    else<br class="">
> -      return nullptr;<br class="">
> +      return false;<br class="">
><br class="">
> +    // Check possible overflow.<br class="">
> +    if (GEPDesc.Start.getActiveBits() > 32 || GEPDesc.Step.getActiveBits() > 32)<br class="">
> +      return false;<br class="">
>     unsigned ElemSize = CDS->getElementType()->getPrimitiveSizeInBits() / 8U;<br class="">
> -    unsigned Start = StartC.getLimitedValue();<br class="">
> -    unsigned Step = StepC.getLimitedValue();<br class="">
> -<br class="">
> -    unsigned Index = (Start + Step * Iteration) / ElemSize;<br class="">
> -    if (Index >= CDS->getNumElements())<br class="">
> -      return nullptr;<br class="">
> +    uint64_t Index = (GEPDesc.Start.getLimitedValue() +<br class="">
> +                      GEPDesc.Step.getLimitedValue() * Iteration) /<br class="">
> +                     ElemSize;<br class="">
> +    if (Index >= CDS->getNumElements()) {<br class="">
> +      // FIXME: For now we conservatively ignore out of bound accesses, but<br class="">
> +      // we're allowed to perform the optimization in this case.<br class="">
> +      return false;<br class="">
> +    }<br class="">
><br class="">
>     Constant *CV = CDS->getElementAsConstant(Index);<br class="">
> +    assert(CV && "Constant expected.");<br class="">
> +    SimplifiedValues[&I] = CV;<br class="">
><br class="">
> -    return CV;<br class="">
> +    NumberOfOptimizedInstructions += TTI.getUserCost(&I);<br class="">
> +    return true;<br class="">
>   }<br class="">
><br class="">
> -public:<br class="">
> -  UnrollAnalyzer(const Loop *L, unsigned TripCount, ScalarEvolution &SE,<br class="">
> -                 const TargetTransformInfo &TTI)<br class="">
> -      : L(L), TripCount(TripCount), SE(SE), TTI(TTI),<br class="">
> -        NumberOfOptimizedInstructions(0) {}<br class="">
> -<br class="">
> -  // Visit all loads the loop L, and for those that, after complete loop<br class="">
> -  // unrolling, would have a constant address and it will point to a known<br class="">
> -  // constant initializer, record its base address for future use.  It is used<br class="">
> -  // when we estimate number of potentially simplified instructions.<br class="">
> -  void findConstFoldableLoads() {<br class="">
> +  /// Visit all GEPs in the loop and find those which after complete loop<br class="">
> +  /// unrolling would become a constant, or BaseAddress+Constant.<br class="">
> +  ///<br class="">
> +  /// Such GEPs could allow to evaluate a load to a constant later - for now we<br class="">
> +  /// just store the corresponding BaseAddress and StartValue with StepValue in<br class="">
> +  /// the SCEVCache.<br class="">
> +  void cacheSCEVResults() {<br class="">
>     for (auto BB : L->getBlocks()) {<br class="">
> -      for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {<br class="">
> -        if (LoadInst *LI = dyn_cast<LoadInst>(I)) {<br class="">
> -          if (!LI->isSimple())<br class="">
> -            continue;<br class="">
> -          Value *AddrOp = LI->getPointerOperand();<br class="">
> -          const SCEV *S = SE.getSCEV(AddrOp);<br class="">
> +      for (Instruction &I : *BB) {<br class="">
> +        if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(&I)) {<br class="">
> +          Value *V = cast<Value>(GEP);<br class="">
> +          if (!SE.isSCEVable(V->getType()))<br class="">
> +              continue;<br class="">
> +          const SCEV *S = SE.getSCEV(V);<br class="">
> +          // FIXME: Hoist the initialization out of the loop.<br class="">
>           FindConstantPointers Visitor(L, SE);<br class="">
>           SCEVTraversal<FindConstantPointers> T(Visitor);<br class="">
> +          // Try to find (BaseAddress+Step+Offset) tuple.<br class="">
> +          // If succeeded, save it to the cache - it might help in folding<br class="">
> +          // loads.<br class="">
>           T.visitAll(S);<br class="">
> -          if (Visitor.IndexIsConstant && Visitor.LoadCanBeConstantFolded) {<br class="">
> -            LoadBaseAddresses[LI] = Visitor.BaseAddress;<br class="">
> -          }<br class="">
> +          if (!Visitor.IndexIsConstant || !Visitor.BaseAddress)<br class="">
> +            continue;<br class="">
> +<br class="">
> +          const SCEV *BaseAddrSE = SE.getSCEV(Visitor.BaseAddress);<br class="">
> +          if (BaseAddrSE->getType() != S->getType())<br class="">
> +            continue;<br class="">
> +          const SCEV *OffSE = SE.getMinusSCEV(S, BaseAddrSE);<br class="">
> +          const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(OffSE);<br class="">
> +<br class="">
> +          if (!AR)<br class="">
> +            continue;<br class="">
> +<br class="">
> +          const SCEVConstant *StepSE =<br class="">
> +              dyn_cast<SCEVConstant>(AR->getStepRecurrence(SE));<br class="">
> +          const SCEVConstant *StartSE = dyn_cast<SCEVConstant>(AR->getStart());<br class="">
> +          if (!StepSE || !StartSE)<br class="">
> +            continue;<br class="">
> +<br class="">
> +          SCEVCache[V] = {Visitor.BaseAddress, StartSE->getValue()->getValue(),<br class="">
> +                          StepSE->getValue()->getValue()};<br class="">
>         }<br class="">
>       }<br class="">
>     }<br class="">
>   }<br class="">
><br class="">
> -  // Given a list of loads that could be constant-folded (LoadBaseAddresses),<br class="">
> -  // estimate number of optimized instructions after substituting the concrete<br class="">
> -  // values for the given Iteration. Also track how many instructions become<br class="">
> -  // dead through this process.<br class="">
> -  unsigned estimateNumberOfOptimizedInstructions(unsigned Iteration) {<br class="">
> -    // We keep a set vector for the worklist so that we don't wast space in the<br class="">
> -    // worklist queuing up the same instruction repeatedly. This can happen due<br class="">
> -    // to multiple operands being the same instruction or due to the same<br class="">
> -    // instruction being an operand of lots of things that end up dead or<br class="">
> -    // simplified.<br class="">
> -    SmallSetVector<Instruction *, 8> Worklist;<br class="">
> -<br class="">
> -    // Clear the simplified values and counts for this iteration.<br class="">
> -    SimplifiedValues.clear();<br class="">
> -    CountedInstructions.clear();<br class="">
> -    NumberOfOptimizedInstructions = 0;<br class="">
> -<br class="">
> -    // We start by adding all loads to the worklist.<br class="">
> -    for (auto &LoadDescr : LoadBaseAddresses) {<br class="">
> -      LoadInst *LI = LoadDescr.first;<br class="">
> -      SimplifiedValues[LI] = computeLoadValue(LI, Iteration);<br class="">
> -      if (CountedInstructions.insert(LI).second)<br class="">
> -        NumberOfOptimizedInstructions += TTI.getUserCost(LI);<br class="">
> +public:<br class="">
> +  UnrollAnalyzer(const Loop *L, unsigned TripCount, ScalarEvolution &SE,<br class="">
> +                 const TargetTransformInfo &TTI, unsigned MaxUnrolledLoopSize)<br class="">
> +      : L(L), TripCount(TripCount), SE(SE), TTI(TTI),<br class="">
> +        MaxUnrolledLoopSize(MaxUnrolledLoopSize),<br class="">
> +        NumberOfOptimizedInstructions(0), UnrolledLoopSize(0) {}<br class="">
><br class="">
> -      for (User *U : LI->users())<br class="">
> -        Worklist.insert(cast<Instruction>(U));<br class="">
> -    }<br class="">
> +  /// \brief Count the number of optimized instructions.<br class="">
> +  unsigned NumberOfOptimizedInstructions;<br class="">
><br class="">
> -    // And then we try to simplify every user of every instruction from the<br class="">
> -    // worklist. If we do simplify a user, add it to the worklist to process<br class="">
> -    // its users as well.<br class="">
> -    while (!Worklist.empty()) {<br class="">
> -      Instruction *I = Worklist.pop_back_val();<br class="">
> -      if (!L->contains(I))<br class="">
> -        continue;<br class="">
> -      if (!visit(I))<br class="">
> -        continue;<br class="">
> -      for (User *U : I->users())<br class="">
> -        Worklist.insert(cast<Instruction>(U));<br class="">
> -    }<br class="">
> +  /// \brief Count the total number of instructions.<br class="">
> +  unsigned UnrolledLoopSize;<br class="">
><br class="">
> -    // Now that we know the potentially simplifed instructions, estimate number<br class="">
> -    // of instructions that would become dead if we do perform the<br class="">
> -    // simplification.<br class="">
> -<br class="">
> -    // The dead instructions are held in a separate set. This is used to<br class="">
> -    // prevent us from re-examining instructions and make sure we only count<br class="">
> -    // the benifit once. The worklist's internal set handles insertion<br class="">
> -    // deduplication.<br class="">
> -    SmallPtrSet<Instruction *, 16> DeadInstructions;<br class="">
> -<br class="">
> -    // Lambda to enque operands onto the worklist.<br class="">
> -    auto EnqueueOperands = [&](Instruction &I) {<br class="">
> -      for (auto *Op : I.operand_values())<br class="">
> -        if (auto *OpI = dyn_cast<Instruction>(Op))<br class="">
> -          if (!OpI->use_empty())<br class="">
> -            Worklist.insert(OpI);<br class="">
> -    };<br class="">
> -<br class="">
> -    // Start by initializing worklist with simplified instructions.<br class="">
> -    for (auto &FoldedKeyValue : SimplifiedValues)<br class="">
> -      if (auto *FoldedInst = dyn_cast<Instruction>(FoldedKeyValue.first)) {<br class="">
> -        DeadInstructions.insert(FoldedInst);<br class="">
> -<br class="">
> -        // Add each instruction operand of this dead instruction to the<br class="">
> -        // worklist.<br class="">
> -        EnqueueOperands(*FoldedInst);<br class="">
> -      }<br class="">
> +  /// \brief Figure out if the loop is worth full unrolling.<br class="">
> +  ///<br class="">
> +  /// Complete loop unrolling can make some loads constant, and we need to know<br class="">
> +  /// if that would expose any further optimization opportunities.  This routine<br class="">
> +  /// estimates this optimization.  It assigns computed number of instructions,<br class="">
> +  /// that potentially might be optimized away, to<br class="">
> +  /// NumberOfOptimizedInstructions, and total number of instructions to<br class="">
> +  /// UnrolledLoopSize (not counting blocks that won't be reached, if we were<br class="">
> +  /// able to compute the condition).<br class="">
> +  /// \returns false if we can't analyze the loop, or if we discovered that<br class="">
> +  /// unrolling won't give anything. Otherwise, returns true.<br class="">
> +  bool analyzeLoop() {<br class="">
> +    SmallSetVector<BasicBlock *, 16> BBWorklist;<br class="">
> +<br class="">
> +    // Don't simulate loops with a big or unknown tripcount<br class="">
> +    if (!UnrollMaxIterationsCountToAnalyze || !TripCount ||<br class="">
> +        TripCount > UnrollMaxIterationsCountToAnalyze)<br class="">
> +      return false;<br class="">
><br class="">
> -    // If a definition of an insn is only used by simplified or dead<br class="">
> -    // instructions, it's also dead. Check defs of all instructions from the<br class="">
> -    // worklist.<br class="">
> -    while (!Worklist.empty()) {<br class="">
> -      Instruction *I = Worklist.pop_back_val();<br class="">
> -      if (!L->contains(I))<br class="">
> -        continue;<br class="">
> -      if (DeadInstructions.count(I))<br class="">
> -        continue;<br class="">
> -<br class="">
> -      if (std::all_of(I->user_begin(), I->user_end(), [&](User *U) {<br class="">
> -            return DeadInstructions.count(cast<Instruction>(U));<br class="">
> -          })) {<br class="">
> -        NumberOfOptimizedInstructions += TTI.getUserCost(I);<br class="">
> -        DeadInstructions.insert(I);<br class="">
> -        EnqueueOperands(*I);<br class="">
> +    // To avoid compute SCEV-expressions on every iteration, compute them once<br class="">
> +    // and store interesting to us in SCEVCache.<br class="">
> +    cacheSCEVResults();<br class="">
> +<br class="">
> +    // Simulate execution of each iteration of the loop counting instructions,<br class="">
> +    // which would be simplified.<br class="">
> +    // Since the same load will take different values on different iterations,<br class="">
> +    // we literally have to go through all loop's iterations.<br class="">
> +    for (Iteration = 0; Iteration < TripCount; ++Iteration) {<br class="">
> +      SimplifiedValues.clear();<br class="">
> +      BBWorklist.clear();<br class="">
> +      BBWorklist.insert(L->getHeader());<br class="">
> +      // Note that we *must not* cache the size, this loop grows the worklist.<br class="">
> +      for (unsigned Idx = 0; Idx != BBWorklist.size(); ++Idx) {<br class="">
> +        BasicBlock *BB = BBWorklist[Idx];<br class="">
> +<br class="">
> +        // Visit all instructions in the given basic block and try to simplify<br class="">
> +        // it.  We don't change the actual IR, just count optimization<br class="">
> +        // opportunities.<br class="">
> +        for (Instruction &I : *BB) {<br class="">
> +          UnrolledLoopSize += TTI.getUserCost(&I);<br class="">
> +          Base::visit(I);<br class="">
> +          // If unrolled body turns out to be too big, bail out.<br class="">
> +          if (UnrolledLoopSize - NumberOfOptimizedInstructions ><br class="">
> +              MaxUnrolledLoopSize)<br class="">
> +            return false;<br class="">
> +        }<br class="">
> +<br class="">
> +        // Add BB's successors to the worklist.<br class="">
> +        for (BasicBlock *Succ : successors(BB))<br class="">
> +          if (L->contains(Succ))<br class="">
> +            BBWorklist.insert(Succ);<br class="">
>       }<br class="">
> +<br class="">
> +      // If we found no optimization opportunities on the first iteration, we<br class="">
> +      // won't find them on later ones too.<br class="">
> +      if (!NumberOfOptimizedInstructions)<br class="">
> +        return false;<br class="">
>     }<br class="">
> -    return NumberOfOptimizedInstructions;<br class="">
> +    return true;<br class="">
>   }<br class="">
> };<br class="">
> } // namespace<br class="">
><br class="">
> -// Complete loop unrolling can make some loads constant, and we need to know if<br class="">
> -// that would expose any further optimization opportunities.<br class="">
> -// This routine estimates this optimization effect and returns the number of<br class="">
> -// instructions, that potentially might be optimized away.<br class="">
> -static unsigned<br class="">
> -approximateNumberOfOptimizedInstructions(const Loop *L, ScalarEvolution &SE,<br class="">
> -                                         unsigned TripCount,<br class="">
> -                                         const TargetTransformInfo &TTI) {<br class="">
> -  if (!TripCount || !UnrollMaxIterationsCountToAnalyze)<br class="">
> -    return 0;<br class="">
> -<br class="">
> -  UnrollAnalyzer UA(L, TripCount, SE, TTI);<br class="">
> -  UA.findConstFoldableLoads();<br class="">
> -<br class="">
> -  // Estimate number of instructions, that could be simplified if we replace a<br class="">
> -  // load with the corresponding constant. Since the same load will take<br class="">
> -  // different values on different iterations, we have to go through all loop's<br class="">
> -  // iterations here. To limit ourselves here, we check only first N<br class="">
> -  // iterations, and then scale the found number, if necessary.<br class="">
> -  unsigned IterationsNumberForEstimate =<br class="">
> -      std::min<unsigned>(UnrollMaxIterationsCountToAnalyze, TripCount);<br class="">
> -  unsigned NumberOfOptimizedInstructions = 0;<br class="">
> -  for (unsigned i = 0; i < IterationsNumberForEstimate; ++i)<br class="">
> -    NumberOfOptimizedInstructions +=<br class="">
> -        UA.estimateNumberOfOptimizedInstructions(i);<br class="">
> -<br class="">
> -  NumberOfOptimizedInstructions *= TripCount / IterationsNumberForEstimate;<br class="">
> -<br class="">
> -  return NumberOfOptimizedInstructions;<br class="">
> -}<br class="">
> -<br class="">
> /// ApproximateLoopSize - Approximate the size of the loop.<br class="">
> static unsigned ApproximateLoopSize(const Loop *L, unsigned &NumCalls,<br class="">
>                                     bool &NotDuplicatable,<br class="">
> @@ -679,6 +681,49 @@ static void SetLoopAlreadyUnrolled(Loop<br class="">
>   L->setLoopID(NewLoopID);<br class="">
> }<br class="">
><br class="">
> +bool LoopUnroll::canUnrollCompletely(<br class="">
> +    Loop *L, unsigned Threshold, unsigned AbsoluteThreshold,<br class="">
> +    uint64_t UnrolledSize, unsigned NumberOfOptimizedInstructions,<br class="">
> +    unsigned PercentOfOptimizedForCompleteUnroll) {<br class="">
> +<br class="">
> +  if (Threshold == NoThreshold) {<br class="">
> +    DEBUG(dbgs() << "  Can fully unroll, because no threshold is set.\n");<br class="">
> +    return true;<br class="">
> +  }<br class="">
> +<br class="">
> +  if (UnrolledSize <= Threshold) {<br class="">
> +    DEBUG(dbgs() << "  Can fully unroll, because unrolled size: "<br class="">
> +                 << UnrolledSize << "<" << Threshold << "\n");<br class="">
> +    return true;<br class="">
> +  }<br class="">
> +<br class="">
> +  assert(UnrolledSize && "UnrolledSize can't be 0 at this point.");<br class="">
> +  unsigned PercentOfOptimizedInstructions =<br class="">
> +      (uint64_t)NumberOfOptimizedInstructions * 100ull / UnrolledSize;<br class="">
> +<br class="">
> +  if (UnrolledSize <= AbsoluteThreshold &&<br class="">
> +      PercentOfOptimizedInstructions >= PercentOfOptimizedForCompleteUnroll) {<br class="">
> +    DEBUG(dbgs() << "  Can fully unroll, because unrolling will help removing "<br class="">
> +                 << PercentOfOptimizedInstructions<br class="">
> +                 << "% instructions (threshold: "<br class="">
> +                 << PercentOfOptimizedForCompleteUnroll << "%)\n");<br class="">
> +    DEBUG(dbgs() << "  Unrolled size (" << UnrolledSize<br class="">
> +                 << ") is less than the threshold (" << AbsoluteThreshold<br class="">
> +                 << ").\n");<br class="">
> +    return true;<br class="">
> +  }<br class="">
> +<br class="">
> +  DEBUG(dbgs() << "  Too large to fully unroll:\n");<br class="">
> +  DEBUG(dbgs() << "    Unrolled size: " << UnrolledSize << "\n");<br class="">
> +  DEBUG(dbgs() << "    Estimated number of optimized instructions: "<br class="">
> +               << NumberOfOptimizedInstructions << "\n");<br class="">
> +  DEBUG(dbgs() << "    Absolute threshold: " << AbsoluteThreshold << "\n");<br class="">
> +  DEBUG(dbgs() << "    Minimum percent of removed instructions: "<br class="">
> +               << PercentOfOptimizedForCompleteUnroll << "\n");<br class="">
> +  DEBUG(dbgs() << "    Threshold for small loops: " << Threshold << "\n");<br class="">
> +  return false;<br class="">
> +}<br class="">
> +<br class="">
> unsigned LoopUnroll::selectUnrollCount(<br class="">
>     const Loop *L, unsigned TripCount, bool PragmaFullUnroll,<br class="">
>     unsigned PragmaCount, const TargetTransformInfo::UnrollingPreferences &UP,<br class="">
> @@ -785,27 +830,34 @@ bool LoopUnroll::runOnLoop(Loop *L, LPPa<br class="">
>     return false;<br class="">
>   }<br class="">
><br class="">
> -  unsigned NumberOfOptimizedInstructions =<br class="">
> -      approximateNumberOfOptimizedInstructions(L, *SE, TripCount, TTI);<br class="">
> -  DEBUG(dbgs() << "  Complete unrolling could save: "<br class="">
> -               << NumberOfOptimizedInstructions << "\n");<br class="">
> -<br class="">
>   unsigned Threshold, PartialThreshold;<br class="">
> +  unsigned AbsoluteThreshold, PercentOfOptimizedForCompleteUnroll;<br class="">
>   selectThresholds(L, HasPragma, UP, Threshold, PartialThreshold,<br class="">
> -                   NumberOfOptimizedInstructions);<br class="">
> +                   AbsoluteThreshold, PercentOfOptimizedForCompleteUnroll);<br class="">
><br class="">
>   // Given Count, TripCount and thresholds determine the type of<br class="">
>   // unrolling which is to be performed.<br class="">
>   enum { Full = 0, Partial = 1, Runtime = 2 };<br class="">
>   int Unrolling;<br class="">
>   if (TripCount && Count == TripCount) {<br class="">
> -    if (Threshold != NoThreshold && UnrolledSize > Threshold) {<br class="">
> -      DEBUG(dbgs() << "  Too large to fully unroll with count: " << Count<br class="">
> -                   << " because size: " << UnrolledSize << ">" << Threshold<br class="">
> -                   << "\n");<br class="">
> -      Unrolling = Partial;<br class="">
> -    } else {<br class="">
> +    Unrolling = Partial;<br class="">
> +    // If the loop is really small, we don't need to run an expensive analysis.<br class="">
> +    if (canUnrollCompletely(<br class="">
> +            L, Threshold, AbsoluteThreshold,<br class="">
> +            UnrolledSize, 0, 100)) {<br class="">
>       Unrolling = Full;<br class="">
> +    } else {<br class="">
> +      // The loop isn't that small, but we still can fully unroll it if that<br class="">
> +      // helps to remove a significant number of instructions.<br class="">
> +      // To check that, run additional analysis on the loop.<br class="">
> +      UnrollAnalyzer UA(L, TripCount, *SE, TTI, AbsoluteThreshold);<br class="">
> +      if (UA.analyzeLoop() &&<br class="">
> +          canUnrollCompletely(L, Threshold, AbsoluteThreshold,<br class="">
> +                              UA.UnrolledLoopSize,<br class="">
> +                              UA.NumberOfOptimizedInstructions,<br class="">
> +                              PercentOfOptimizedForCompleteUnroll)) {<br class="">
> +        Unrolling = Full;<br class="">
> +      }<br class="">
>     }<br class="">
>   } else if (TripCount && Count < TripCount) {<br class="">
>     Unrolling = Partial;<br class="">
><br class="">
> Added: llvm/trunk/test/Transforms/LoopUnroll/full-unroll-bad-geps.ll<br class="">
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_test_Transforms_LoopUnroll_full-2Dunroll-2Dbad-2Dgeps.ll-3Frev-3D237156-26view-3Dauto&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=6UzI8VuZg4hVPZsdf6eMAODupqaq32_-5DO7Jh3KQXY&s=IKAKyEzc6xhFFUTHJMDNpgfFDdIrJCAlv02kXUVVkpw&e=" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopUnroll/full-unroll-bad-geps.ll?rev=237156&view=auto</a><br class="">
> ==============================================================================<br class="">
> --- llvm/trunk/test/Transforms/LoopUnroll/full-unroll-bad-geps.ll (added)<br class="">
> +++ llvm/trunk/test/Transforms/LoopUnroll/full-unroll-bad-geps.ll Tue May 12 12:20:03 2015<br class="">
> @@ -0,0 +1,34 @@<br class="">
> +; Check that we don't crash on corner cases.<br class="">
> +; RUN: opt < %s -S -loop-unroll -unroll-max-iteration-count-to-analyze=1000 -unroll-absolute-threshold=10  -unroll-threshold=10  -unroll-percent-of-optimized-for-complete-unroll=20 -o /dev/null<br class="">
> +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"<br class="">
> +<br class="">
> +define void @foo1() {<br class="">
> +entry:<br class="">
> +  br label %for.body<br class="">
> +<br class="">
> +for.body:<br class="">
> +  %phi = phi i64 [ 0, %entry ], [ %inc, %for.body ]<br class="">
> +  %idx = zext i32 undef to i64<br class="">
> +  %add.ptr = getelementptr inbounds i64, i64* null, i64 %idx<br class="">
> +  %inc = add nuw nsw i64 %phi, 1<br class="">
> +  %cmp = icmp ult i64 %inc, 999<br class="">
> +  br i1 %cmp, label %for.body, label %for.exit<br class="">
> +<br class="">
> +for.exit:<br class="">
> +  ret void<br class="">
> +}<br class="">
> +<br class="">
> +define void @foo2() {<br class="">
> +entry:<br class="">
> +  br label %for.body<br class="">
> +<br class="">
> +for.body:<br class="">
> +  %phi = phi i64 [ 0, %entry ], [ %inc, %for.body ]<br class="">
> +  %x = getelementptr i32, <4 x i32*> undef, <4 x i32> <i32 1, i32 1, i32 1, i32 1><br class="">
> +  %inc = add nuw nsw i64 %phi, 1<br class="">
> +  %cmp = icmp ult i64 %inc, 999<br class="">
> +  br i1 %cmp, label %for.body, label %for.exit<br class="">
> +<br class="">
> +for.exit:<br class="">
> +  ret void<br class="">
> +}<br class="">
><br class="">
> Modified: llvm/trunk/test/Transforms/LoopUnroll/full-unroll-heuristics.ll<br class="">
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_test_Transforms_LoopUnroll_full-2Dunroll-2Dheuristics.ll-3Frev-3D237156-26r1-3D237155-26r2-3D237156-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=6UzI8VuZg4hVPZsdf6eMAODupqaq32_-5DO7Jh3KQXY&s=SF56CWre4zNWgmRvLqbFmmdclqg7ImCBooXRvkT4KUA&e=" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopUnroll/full-unroll-heuristics.ll?rev=237156&r1=237155&r2=237156&view=diff</a><br class="">
> ==============================================================================<br class="">
> --- llvm/trunk/test/Transforms/LoopUnroll/full-unroll-heuristics.ll (original)<br class="">
> +++ llvm/trunk/test/Transforms/LoopUnroll/full-unroll-heuristics.ll Tue May 12 12:20:03 2015<br class="">
> @@ -17,8 +17,8 @@<br class="">
> ; optimizations to remove ~55% of the instructions, the loop body size is 9,<br class="">
> ; and unrolled size is 65.<br class="">
><br class="">
> -; RUN: opt < %s -S -loop-unroll -unroll-max-iteration-count-to-analyze=1000 -unroll-absolute-threshold=10  -unroll-threshold=10  -unroll-percent-of-optimized-for-complete-unroll=30 | FileCheck %s -check-prefix=TEST1<br class="">
> -; RUN: opt < %s -S -loop-unroll -unroll-max-iteration-count-to-analyze=1000 -unroll-absolute-threshold=100 -unroll-threshold=10  -unroll-percent-of-optimized-for-complete-unroll=30 | FileCheck %s -check-prefix=TEST2<br class="">
> +; RUN: opt < %s -S -loop-unroll -unroll-max-iteration-count-to-analyze=1000 -unroll-absolute-threshold=10  -unroll-threshold=10  -unroll-percent-of-optimized-for-complete-unroll=20 | FileCheck %s -check-prefix=TEST1<br class="">
> +; RUN: opt < %s -S -loop-unroll -unroll-max-iteration-count-to-analyze=1000 -unroll-absolute-threshold=100 -unroll-threshold=10  -unroll-percent-of-optimized-for-complete-unroll=20 | FileCheck %s -check-prefix=TEST2<br class="">
> ; RUN: opt < %s -S -loop-unroll -unroll-max-iteration-count-to-analyze=1000 -unroll-absolute-threshold=100 -unroll-threshold=10  -unroll-percent-of-optimized-for-complete-unroll=80 | FileCheck %s -check-prefix=TEST3<br class="">
> ; RUN: opt < %s -S -loop-unroll -unroll-max-iteration-count-to-analyze=1000 -unroll-absolute-threshold=100 -unroll-threshold=100 -unroll-percent-of-optimized-for-complete-unroll=80 | FileCheck %s -check-prefix=TEST4<br class="">
><br class="">
><br class="">
><br class="">
> _______________________________________________<br class="">
> llvm-commits mailing list<br class="">
> <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank" class="">llvm-commits@cs.uiuc.edu</a><br class="">
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank" class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br class="">
<br class="">
</blockquote></div>
</div></blockquote></div><br class=""></body></html>