OSDN Git Service

[SCEV] Make computeExitLimit more simple and more powerful
authorMax Kazantsev <max.kazantsev@azul.com>
Tue, 3 Apr 2018 05:57:19 +0000 (05:57 +0000)
committerMax Kazantsev <max.kazantsev@azul.com>
Tue, 3 Apr 2018 05:57:19 +0000 (05:57 +0000)
commit023c8be90980e0180766196cba86f81608b35d38
treed5fb6618463f0bf60e040a5b4fe2d6537a5977aa
parent8b74007e1a3c1b4422305598076dc848dcc526f8
[SCEV] Make computeExitLimit more simple and more powerful

Current implementation of `computeExitLimit` has a big piece of code
the only purpose of which is to prove that after the execution of this
block the latch will be executed. What it currently checks is actually a
subset of situations where the exiting block dominates latch.

This patch replaces all these checks for simple particular cases with
domination check over loop's latch which is the only necessary condition
of taking the exiting block into consideration. This change allows to
calculate exact loop taken count for simple loops like

  for (int i = 0; i < 100; i++) {
    if (cond) {...} else {...}
    if (i > 50) break;
    . . .
  }

Differential Revision: https://reviews.llvm.org/D44677
Reviewed By: efriedma

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329047 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/ScalarEvolution.cpp
test/Analysis/ScalarEvolution/exact_iter_count.ll