[llvm] r303497 - [SCEV] Clarify behavior around max backedge taken count

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Sat May 20 22:18:34 PDT 2017


Clang instrumented with msan (stage2) is building new clang (stage3).

Easy but slow reproducer is to go to empty dir and run command below:
BUILDBOT_REVISION=303497 BUILDBOT_CLOBBER=1 <path to llvm
checkout>/projects/zorg/zorg/buildbot/builders/sanitizers/buildbot_bootstrap.sh

On Sat, May 20, 2017 at 10:02 PM, Sanjoy Das <sanjoy at playingwithpointers.com
> wrote:

> Reverted in r303498
>
> On Sat, May 20, 2017 at 9:59 PM, Sanjoy Das
> <sanjoy at playingwithpointers.com> wrote:
> > Hi Vitaly,
> >
> > I'm about to revert this change, but I have a question -- what this
> > failure seen when the ToT clang (built with a "known good" clang +
> > msan) tried to build itself, or when a bootstrapped clang (i.e. a
> > clang built with a ToT clang + msan) tried to bootstrap itself?
> >
> > Thanks
> > -- Sanjoy
> >
> > On Sat, May 20, 2017 at 9:49 PM, Vitaly Buka <vitalybuka at google.com>
> wrote:
> >> http://lab.llvm.org:8011/builders/sanitizer-x86_64-
> linux-bootstrap/builds/1379/steps/check-llvm%20check-
> clang%20stage3%2Fmsan/logs/stdio
> >>
> >> FAILED: tools/llvm-xray/CMakeFiles/llvm-xray.dir/xray-color-helper.cc.o
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm_build_msan/bin/clang++
> >> -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_GLOBAL_ISEL -D_DEBUG -D_GNU_SOURCE
> >> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> >> -Itools/llvm-xray
> >> -I/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/llvm-xray
> >> -Iinclude
> >> -I/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/include
> >> -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W
> >> -Wno-unused-parameter -Wwrite-strings -Wcast-qual
> >> -Wmissing-field-initializers -pedantic -Wno-long-long
> >> -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor
> >> -Wstring-conversion -fcolor-diagnostics -ffunction-sections
> -fdata-sections
> >> -O3    -UNDEBUG  -fno-exceptions -fno-rtti -MD -MT
> >> tools/llvm-xray/CMakeFiles/llvm-xray.dir/xray-color-helper.cc.o -MF
> >> tools/llvm-xray/CMakeFiles/llvm-xray.dir/xray-color-helper.cc.o.d -o
> >> tools/llvm-xray/CMakeFiles/llvm-xray.dir/xray-color-helper.cc.o -c
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/llvm-xray/xray-color-helper.cc
> >> ==969==WARNING: MemorySanitizer: use-of-uninitialized-value
> >>     #0 0x3533258 in
> >> llvm::X86InstrInfo::AnalyzeBranchImpl(llvm::MachineBasicBlock&,
> >> llvm::MachineBasicBlock*&, llvm::MachineBasicBlock*&,
> >> llvm::SmallVectorImpl<llvm::MachineOperand>&,
> >> llvm::SmallVectorImpl<llvm::MachineInstr*>&, bool) const
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/lib/Target/X86/X86InstrInfo.cpp:6093:22
> >>     #1 0x353333d in
> >> llvm::X86InstrInfo::analyzeBranch(llvm::MachineBasicBlock&,
> >> llvm::MachineBasicBlock*&, llvm::MachineBasicBlock*&,
> >> llvm::SmallVectorImpl<llvm::MachineOperand>&, bool) const
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/lib/Target/X86/X86InstrInfo.cpp:6133:10
> >>     #2 0x42fddcc in llvm::TailDuplicator::tailDuplicate(bool,
> >> llvm::MachineBasicBlock*, llvm::MachineBasicBlock*,
> >> llvm::SmallVectorImpl<llvm::MachineBasicBlock*>&,
> >> llvm::SmallVectorImpl<llvm::MachineInstr*>&)
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/lib/CodeGen/TailDuplicator.cpp:837:10
> >>     #3 0x42fab3a in llvm::TailDuplicator::tailDuplicateAndUpdate(bool,
> >> llvm::MachineBasicBlock*, llvm::MachineBasicBlock*,
> >> llvm::SmallVectorImpl<llvm::MachineBasicBlock*>*,
> llvm::function_ref<void
> >> (llvm::MachineBasicBlock*)>*)
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/lib/CodeGen/TailDuplicator.cpp:148:8
> >>     #4 0x44e921b in (anonymous
> >> namespace)::MachineBlockPlacement::maybeTailDuplicateBlock(llvm::
> MachineBasicBlock*,
> >> llvm::MachineBasicBlock*, (anonymous namespace)::BlockChain&,
> >> llvm::SmallSetVector<llvm::MachineBasicBlock const*, 16u>*,
> >> llvm::ilist_iterator<llvm::ilist_detail::node_options<
> llvm::MachineBasicBlock,
> >> true, false, void>, false, false>&, bool&)
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/lib/CodeGen/MachineBlockPlacement.cpp:2620:11
> >>     #5 0x44cef5d in repeatedlyTailDuplicateBlock
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/lib/CodeGen/MachineBlockPlacement.cpp:2501:13
> >>     #6 0x44cef5d in (anonymous
> >> namespace)::MachineBlockPlacement::buildChain(llvm::MachineBasicBlock
> >> const*, (anonymous namespace)::BlockChain&,
> >> llvm::SmallSetVector<llvm::MachineBasicBlock const*, 16u>*)
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/lib/CodeGen/MachineBlockPlacement.cpp:1699
> >>     #7 0x44b6970 in (anonymous
> >> namespace)::MachineBlockPlacement::buildCFGChains()
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/lib/CodeGen/MachineBlockPlacement.cpp:2278:3
> >>     #8 0x44b14a9 in (anonymous
> >> namespace)::MachineBlockPlacement::runOnMachineFunction(llvm::
> MachineFunction&)
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/lib/CodeGen/MachineBlockPlacement.cpp:2696:3
> >>     #9 0x3f6dcac in
> >> llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/lib/CodeGen/MachineFunctionPass.cpp:62:13
> >>     #10 0x48e2bee in llvm::FPPassManager::
> runOnFunction(llvm::Function&)
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/lib/IR/LegacyPassManager.cpp:1519:27
> >>     #11 0x48e32b4 in llvm::FPPassManager::runOnModule(llvm::Module&)
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/lib/IR/LegacyPassManager.cpp:1540:16
> >>     #12 0x48e45d3 in runOnModule
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/lib/IR/LegacyPassManager.cpp:1596:27
> >>     #13 0x48e45d3 in llvm::legacy::PassManagerImpl::run(llvm::Module&)
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/lib/IR/LegacyPassManager.cpp:1699
> >>     #14 0x5d3e27e in EmitAssembly
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:792:19
> >>     #15 0x5d3e27e in clang::EmitBackendOutput(
> clang::DiagnosticsEngine&,
> >> clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
> >> clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
> >> const&, llvm::Module*, clang::BackendAction,
> >> std::__1::unique_ptr<llvm::raw_pwrite_stream,
> >> std::__1::default_delete<llvm::raw_pwrite_stream> >)
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:1101
> >>     #16 0x74dfefe in
> >> clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:258:7
> >>     #17 0x848e176 in clang::ParseAST(clang::Sema&, bool, bool)
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/lib/Parse/ParseAST.cpp:159:13
> >>     #18 0x69f82ba in clang::FrontendAction::Execute()
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:837:8
> >>     #19 0x693a02c in
> >> clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:970:11
> >>     #20 0x6bc3705 in
> >> clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/lib/FrontendTool/
> ExecuteCompilerInvocation.cpp:249:25
> >>     #21 0x976e25 in cc1_main(llvm::ArrayRef<char const*>, char const*,
> >> void*)
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/tools/driver/cc1_main.cpp:221:13
> >>     #22 0x970ce7 in ExecuteCC1Tool
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/tools/driver/driver.cpp:299:12
> >>     #23 0x970ce7 in main
> >> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/tools/driver/driver.cpp:380
> >>     #24 0x7f561ec5c82f in __libc_start_main
> >> (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
> >>     #25 0x8f0d38 in _start
> >> (/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm_build_msan/bin/clang-5.0+0x8f0d38)
> >>
> >>
> >> On Sat, May 20, 2017 at 6:47 PM, Sanjoy Das via llvm-commits
> >> <llvm-commits at lists.llvm.org> wrote:
> >>>
> >>> Author: sanjoy
> >>> Date: Sat May 20 20:47:50 2017
> >>> New Revision: 303497
> >>>
> >>> URL: http://llvm.org/viewvc/llvm-project?rev=303497&view=rev
> >>> Log:
> >>> [SCEV] Clarify behavior around max backedge taken count
> >>>
> >>> This change makes the split between the "exact" backedge taken count
> >>> and the "maximum" backedge taken count a bit more obvious.  Both of
> >>> these are upper bounds on the number of times the loop header
> >>> executes (since SCEV does not account for most kinds of abnormal
> >>> control flow), but the latter is guaranteed to be a constant.
> >>>
> >>> There were a few places where the max backedge taken count *was* a
> >>> non-constant; I've changed those to compute constants instead.
> >>>
> >>> At this point, I'm not sure if the constant max backedge count can be
> >>> computed by calling `getUnsignedRange(Exact).getUnsignedMax()` without
> >>> losing precision.  If it can, we can simplify even further by making
> >>> `getMaxBackedgeTakenCount` a thin wrapper around
> >>> `getBackedgeTakenCount` and `getUnsignedRange`.
> >>>
> >>> Modified:
> >>>     llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
> >>>     llvm/trunk/lib/Analysis/ScalarEvolution.cpp
> >>>     llvm/trunk/test/Analysis/ScalarEvolution/nsw.ll
> >>>     llvm/trunk/test/Analysis/ScalarEvolution/trip-count-pow2.ll
> >>>
> >>> Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
> >>> URL:
> >>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/
> llvm/Analysis/ScalarEvolution.h?rev=303497&r1=303496&r2=303497&view=diff
> >>>
> >>> ============================================================
> ==================
> >>> --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original)
> >>> +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Sat May 20
> 20:47:50
> >>> 2017
> >>> @@ -656,10 +656,12 @@ private:
> >>>      /// Test whether this BackedgeTakenInfo contains complete
> >>> information.
> >>>      bool hasFullInfo() const { return isComplete(); }
> >>>
> >>> -    /// Return an expression indicating the exact backedge-taken
> count of
> >>> the
> >>> -    /// loop if it is known or SCEVCouldNotCompute otherwise. This is
> the
> >>> -    /// number of times the loop header can be guaranteed to execute,
> >>> minus
> >>> -    /// one.
> >>> +    /// Return an expression indicating the exact *backedge-taken*
> >>> +    /// count of the loop if it is known or SCEVCouldNotCompute
> >>> +    /// otherwise.  If execution makes it to the backedge on every
> >>> +    /// iteration (i.e. there are no abnormal exists like exception
> >>> +    /// throws and thread exits) then this is the number of times the
> >>> +    /// loop header will execute minus one.
> >>>      ///
> >>>      /// If the SCEV predicate associated with the answer can be
> different
> >>>      /// from AlwaysTrue, we must add a (non null) Predicates argument.
> >>> @@ -1398,11 +1400,11 @@ public:
> >>>    const SCEV *getExitCount(const Loop *L, BasicBlock *ExitingBlock);
> >>>
> >>>    /// If the specified loop has a predictable backedge-taken count,
> >>> return it,
> >>> -  /// otherwise return a SCEVCouldNotCompute object. The
> backedge-taken
> >>> count
> >>> -  /// is the number of times the loop header will be branched to from
> >>> within
> >>> -  /// the loop. This is one less than the trip count of the loop,
> since
> >>> it
> >>> -  /// doesn't count the first iteration, when the header is branched
> to
> >>> from
> >>> -  /// outside the loop.
> >>> +  /// otherwise return a SCEVCouldNotCompute object. The
> backedge-taken
> >>> count is
> >>> +  /// the number of times the loop header will be branched to from
> within
> >>> the
> >>> +  /// loop, assuming there are no abnormal exists like exception
> throws.
> >>> This is
> >>> +  /// one less than the trip count of the loop, since it doesn't count
> >>> the first
> >>> +  /// iteration, when the header is branched to from outside the loop.
> >>>    ///
> >>>    /// Note that it is not valid to call this method on a loop without
> a
> >>>    /// loop-invariant backedge-taken count (see
> >>> @@ -1417,8 +1419,10 @@ public:
> >>>    const SCEV *getPredicatedBackedgeTakenCount(const Loop *L,
> >>>                                                SCEVUnionPredicate
> >>> &Predicates);
> >>>
> >>> -  /// Similar to getBackedgeTakenCount, except return the least SCEV
> >>> value
> >>> -  /// that is known never to be less than the actual backedge taken
> >>> count.
> >>> +  /// When successful, this returns a SCEVConstant that is greater
> than
> >>> or equal
> >>> +  /// to (i.e. a "conservative over-approximation") of the value
> returend
> >>> by
> >>> +  /// getBackedgeTakenCount.  If such a value cannot be computed, it
> >>> returns the
> >>> +  /// SCEVCouldNotCompute object.
> >>>    const SCEV *getMaxBackedgeTakenCount(const Loop *L);
> >>>
> >>>    /// Return true if the backedge taken count is either the value
> >>> returned by
> >>>
> >>> Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
> >>> URL:
> >>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> Analysis/ScalarEvolution.cpp?rev=303497&r1=303496&r2=303497&view=diff
> >>>
> >>> ============================================================
> ==================
> >>> --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
> >>> +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Sat May 20 20:47:50
> 2017
> >>> @@ -5947,6 +5947,8 @@ ScalarEvolution::BackedgeTakenInfo::getM
> >>>    if (any_of(ExitNotTaken, PredicateNotAlwaysTrue) || !getMax())
> >>>      return SE->getCouldNotCompute();
> >>>
> >>> +  assert((isa<SCEVCouldNotCompute>(getMax()) ||
> >>> isa<SCEVConstant>(getMax())) &&
> >>> +         "No point in having a non-constant max backedge taken
> count!");
> >>>    return getMax();
> >>>  }
> >>>
> >>> @@ -5972,7 +5974,11 @@ bool ScalarEvolution::BackedgeTakenInfo:
> >>>  }
> >>>
> >>>  ScalarEvolution::ExitLimit::ExitLimit(const SCEV *E)
> >>> -    : ExactNotTaken(E), MaxNotTaken(E), MaxOrZero(false) {}
> >>> +    : ExactNotTaken(E), MaxNotTaken(E), MaxOrZero(false) {
> >>> +  assert((isa<SCEVCouldNotCompute>(MaxNotTaken) ||
> >>> +          isa<SCEVConstant>(MaxNotTaken)) &&
> >>> +         "No point in having a non-constant max backedge taken
> count!");
> >>> +}
> >>>
> >>>  ScalarEvolution::ExitLimit::ExitLimit(
> >>>      const SCEV *E, const SCEV *M, bool MaxOrZero,
> >>> @@ -5981,6 +5987,9 @@ ScalarEvolution::ExitLimit::ExitLimit(
> >>>    assert((isa<SCEVCouldNotCompute>(ExactNotTaken) ||
> >>>            !isa<SCEVCouldNotCompute>(MaxNotTaken)) &&
> >>>           "Exact is not allowed to be less precise than Max");
> >>> +  assert((isa<SCEVCouldNotCompute>(MaxNotTaken) ||
> >>> +          isa<SCEVConstant>(MaxNotTaken)) &&
> >>> +         "No point in having a non-constant max backedge taken
> count!");
> >>>    for (auto *PredSet : PredSetList)
> >>>      for (auto *P : *PredSet)
> >>>        addPredicate(P);
> >>> @@ -5989,11 +5998,19 @@ ScalarEvolution::ExitLimit::ExitLimit(
> >>>  ScalarEvolution::ExitLimit::ExitLimit(
> >>>      const SCEV *E, const SCEV *M, bool MaxOrZero,
> >>>      const SmallPtrSetImpl<const SCEVPredicate *> &PredSet)
> >>> -    : ExitLimit(E, M, MaxOrZero, {&PredSet}) {}
> >>> +    : ExitLimit(E, M, MaxOrZero, {&PredSet}) {
> >>> +  assert((isa<SCEVCouldNotCompute>(MaxNotTaken) ||
> >>> +          isa<SCEVConstant>(MaxNotTaken)) &&
> >>> +         "No point in having a non-constant max backedge taken
> count!");
> >>> +}
> >>>
> >>>  ScalarEvolution::ExitLimit::ExitLimit(const SCEV *E, const SCEV *M,
> >>>                                        bool MaxOrZero)
> >>> -    : ExitLimit(E, M, MaxOrZero, None) {}
> >>> +    : ExitLimit(E, M, MaxOrZero, None) {
> >>> +  assert((isa<SCEVCouldNotCompute>(MaxNotTaken) ||
> >>> +          isa<SCEVConstant>(MaxNotTaken)) &&
> >>> +         "No point in having a non-constant max backedge taken
> count!");
> >>> +}
> >>>
> >>>  /// Allocate memory for BackedgeTakenInfo and copy the not-taken
> count of
> >>> each
> >>>  /// computable exit into a persistent ExitNotTakenInfo array.
> >>> @@ -6018,6 +6035,8 @@ ScalarEvolution::BackedgeTakenInfo::Back
> >>>
> >>>          return ExitNotTakenInfo(ExitBB, EL.ExactNotTaken,
> >>> std::move(Predicate));
> >>>        });
> >>> +  assert((isa<SCEVCouldNotCompute>(MaxCount) ||
> >>> isa<SCEVConstant>(MaxCount)) &&
> >>> +         "No point in having a non-constant max backedge taken
> count!");
> >>>  }
> >>>
> >>>  /// Invalidate this result and free the ExitNotTakenInfo array.
> >>> @@ -6279,7 +6298,7 @@ ScalarEvolution::ExitLimit ScalarEvoluti
> >>>        // to not.
> >>>        if (isa<SCEVCouldNotCompute>(MaxBECount) &&
> >>>            !isa<SCEVCouldNotCompute>(BECount))
> >>> -        MaxBECount = BECount;
> >>> +        MaxBECount =
> >>> getConstant(getUnsignedRange(BECount).getUnsignedMax());
> >>>
> >>>        return ExitLimit(BECount, MaxBECount, false,
> >>>                         {&EL0.Predicates, &EL1.Predicates});
> >>> @@ -7583,13 +7602,20 @@ ScalarEvolution::howFarToZero(const SCEV
> >>>        loopHasNoAbnormalExits(AddRec->getLoop())) {
> >>>      const SCEV *Exact =
> >>>          getUDivExpr(Distance, CountDown ? getNegativeSCEV(Step) :
> Step);
> >>> -    return ExitLimit(Exact, Exact, false, Predicates);
> >>> +    const SCEV *Max =
> >>> +        Exact == getCouldNotCompute()
> >>> +            ? Exact
> >>> +            : getConstant(getUnsignedRange(Exact).getUnsignedMax());
> >>> +    return ExitLimit(Exact, Max, false, Predicates);
> >>>    }
> >>>
> >>>    // Solve the general equation.
> >>> -  const SCEV *E = SolveLinEquationWithOverflow(
> >>> -      StepC->getAPInt(), getNegativeSCEV(Start), *this);
> >>> -  return ExitLimit(E, E, false, Predicates);
> >>> +  const SCEV *E = SolveLinEquationWithOverflow(StepC->getAPInt(),
> >>> +                                               getNegativeSCEV(Start),
> >>> *this);
> >>> +  const SCEV *M = E == getCouldNotCompute()
> >>> +                      ? E
> >>> +                      :
> >>> getConstant(getUnsignedRange(E).getUnsignedMax());
> >>> +  return ExitLimit(E, M, false, Predicates);
> >>>  }
> >>>
> >>>  ScalarEvolution::ExitLimit
> >>> @@ -9218,8 +9244,9 @@ ScalarEvolution::howManyLessThans(const
> >>>                                  getConstant(StrideForMaxBECount),
> false);
> >>>    }
> >>>
> >>> -  if (isa<SCEVCouldNotCompute>(MaxBECount))
> >>> -    MaxBECount = BECount;
> >>> +  if (isa<SCEVCouldNotCompute>(MaxBECount) &&
> >>> +      !isa<SCEVCouldNotCompute>(BECount))
> >>> +    MaxBECount = getConstant(getUnsignedRange(
> BECount).getUnsignedMax());
> >>>
> >>>    return ExitLimit(BECount, MaxBECount, MaxOrZero, Predicates);
> >>>  }
> >>>
> >>> Modified: llvm/trunk/test/Analysis/ScalarEvolution/nsw.ll
> >>> URL:
> >>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/
> Analysis/ScalarEvolution/nsw.ll?rev=303497&r1=303496&r2=303497&view=diff
> >>>
> >>> ============================================================
> ==================
> >>> --- llvm/trunk/test/Analysis/ScalarEvolution/nsw.ll (original)
> >>> +++ llvm/trunk/test/Analysis/ScalarEvolution/nsw.ll Sat May 20
> 20:47:50
> >>> 2017
> >>> @@ -102,7 +102,7 @@ for.body.i.i:
> >>>    %cmp.i.i = icmp eq i32* %ptrincdec.i.i, %end
> >>>    br i1 %cmp.i.i, label %_ZSt4fillIPiiEvT_S1_RKT0_.exit, label
> >>> %for.body.i.i
> >>>  ; CHECK: Loop %for.body.i.i: backedge-taken count is ((-4 + (-1 *
> %begin)
> >>> + %end) /u 4)
> >>> -; CHECK: Loop %for.body.i.i: max backedge-taken count is ((-4 + (-1 *
> >>> %begin) + %end) /u 4)
> >>> +; CHECK: Loop %for.body.i.i: max backedge-taken count is
> >>> 4611686018427387903
> >>>  _ZSt4fillIPiiEvT_S1_RKT0_.exit:                   ; preds =
> >>> %for.body.i.i, %entry
> >>>    ret void
> >>>  }
> >>>
> >>> Modified: llvm/trunk/test/Analysis/ScalarEvolution/trip-count-pow2.ll
> >>> URL:
> >>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/
> Analysis/ScalarEvolution/trip-count-pow2.ll?rev=303497&r1=
> 303496&r2=303497&view=diff
> >>>
> >>> ============================================================
> ==================
> >>> --- llvm/trunk/test/Analysis/ScalarEvolution/trip-count-pow2.ll
> (original)
> >>> +++ llvm/trunk/test/Analysis/ScalarEvolution/trip-count-pow2.ll Sat
> May 20
> >>> 20:47:50 2017
> >>> @@ -14,7 +14,7 @@ exit:
> >>>
> >>>  ; CHECK-LABEL: @test1
> >>>  ; CHECK: Loop %loop: backedge-taken count is ((-32 + (96 * %n)) /u 32)
> >>> -; CHECK: Loop %loop: max backedge-taken count is ((-32 + (96 * %n)) /u
> >>> 32)
> >>> +; CHECK: Loop %loop: max backedge-taken count is 134217727
> >>>  }
> >>>
> >>>  ; PR19183
> >>> @@ -32,7 +32,7 @@ exit:
> >>>
> >>>  ; CHECK-LABEL: @test2
> >>>  ; CHECK: Loop %loop: backedge-taken count is ((-32 + (32 * (%n /u
> 32)))
> >>> /u 32)
> >>> -; CHECK: Loop %loop: max backedge-taken count is ((-32 + (32 * (%n /u
> >>> 32))) /u 32)
> >>> +; CHECK: Loop %loop: max backedge-taken count is 134217727
> >>>  }
> >>>
> >>>  define void @test3(i32 %n) {
> >>> @@ -49,7 +49,7 @@ exit:
> >>>
> >>>  ; CHECK-LABEL: @test3
> >>>  ; CHECK: Loop %loop: backedge-taken count is ((-32 + (32 * %n)) /u 32)
> >>> -; CHECK: Loop %loop: max backedge-taken count is ((-32 + (32 * %n)) /u
> >>> 32)
> >>> +; CHECK: Loop %loop: max backedge-taken count is 134217727
> >>>  }
> >>>
> >>>  define void @test4(i32 %n) {
> >>> @@ -66,7 +66,7 @@ exit:
> >>>
> >>>  ; CHECK-LABEL: @test4
> >>>  ; CHECK: Loop %loop: backedge-taken count is ((-4 + (-1431655764 *
> %n))
> >>> /u 4)
> >>> -; CHECK: Loop %loop: max backedge-taken count is ((-4 + (-1431655764 *
> >>> %n)) /u 4)
> >>> +; CHECK: Loop %loop: max backedge-taken count is 1073741823
> >>>  }
> >>>
> >>>  define void @test5(i32 %n) {
> >>> @@ -83,5 +83,5 @@ exit:
> >>>
> >>>  ; CHECK-LABEL: @test5
> >>>  ; CHECK: Loop %loop: backedge-taken count is ((-4 + (4 * %n)) /u 4)
> >>> -; CHECK: Loop %loop: max backedge-taken count is ((-4 + (4 * %n)) /u
> 4)
> >>> +; CHECK: Loop %loop: max backedge-taken count is 1073741823
> >>>  }
> >>>
> >>>
> >>> _______________________________________________
> >>> llvm-commits mailing list
> >>> llvm-commits at lists.llvm.org
> >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> >>
> >>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170520/d770441f/attachment.html>


More information about the llvm-commits mailing list