[SCEV][NFC] Remove TBB, FBB parameters from exit limit computations
authorMax Kazantsev <max.kazantsev@azul.com>
Thu, 15 Mar 2018 09:38:00 +0000 (09:38 +0000)
committerMax Kazantsev <max.kazantsev@azul.com>
Thu, 15 Mar 2018 09:38:00 +0000 (09:38 +0000)
commit4f9c7c5086696f0baea1b0a8125272f6c2ebc265
tree2fcdcccbd23e2c82354ff2b0d6ff279f5bae0ea0
parent76f1c78deafe289a6a73743bf8e2987738d75ed3
[SCEV][NFC] Remove TBB, FBB parameters from exit limit computations

Methods `computeExitLimitFromCondCached` and `computeExitLimitFromCondImpl` take
true and false branches as parameters and only use them for asserts and for identifying
whether true/false branch belongs to the loop (which can be done once earlier). This fact
complicates generalization of exit limit computation logic on guards because the guards
don't have blocks to which they go in case of failure explicitly.

The motivation of this patch is that currently this part of SCEV knows nothing about guards
and only works with explicit branches. As result, it fails to prove that a loop

  for (i = 0; i < 100; i++)
    guard(i < 10);

exits after 10th iteration, while in the equivalent example

  for (i = 0; i < 100; i++)
    if (i >= 10) break;

SCEV easily proves this fact. We are going to change it in near future, and this is why
we need to make these methods operate on more abstract level.

This patch refactors this code to get rid of these parameters as meaningless and prepare
ground for teaching these methods to work with guards as well as they work with explicit
branching instructions.

Differential Revision: https://reviews.llvm.org/D44419

llvm-svn: 327615
llvm/include/llvm/Analysis/ScalarEvolution.h
llvm/lib/Analysis/ScalarEvolution.cpp