Merging 182989: Fix ScalarEvolution::ComputeExitLimitFromCond for 'or' conditions.

    Fixes PR16130 - clang produces incorrect code with loop/expression at -O2.

    This is a 2+ year old bug that's now holding up the release. It's a
    case where we knowingly made aggressive assumptions about undefined
    behavior. These assumptions are wrong when SCEV is computing a
    subexpression that does not directly control the branch. With this
    fix, we avoid making assumptions in those cases but still optimize the
    common case. SCEV's trip count computation for exits controlled by
    'or' expressions is now analagous to the trip count computation for
    loops with multiple exits. I had already fixed the multiple exit case
    to be conservative.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182989 91177308-0d34-0410-b5e6-96231b3b80d8



git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_33@183013 91177308-0d34-0410-b5e6-96231b3b80d8
Merge 183060: Prevent loop-unroll from making assumptions about undefined behavior.

    Fixes rdar:14036816, PR16130.

    There is an opportunity to compute precise trip counts for 'or'
    expressions and multi-exit loops.
    rdar:14038809: Optimize trip count computation for multi-exit loops.

    To do this we need to record the fact that ExitLimit assumes NSW. When
    it does not we can safely assume that the loop trip count is the
    minimum ExitLimt across all subexpressions and loop exits.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183060 91177308-0d34-0410-b5e6-96231b3b80d8


git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_33@183066 91177308-0d34-0410-b5e6-96231b3b80d8