OSDN Git Service

[ScalarEvolution] Re-enable Predicate implication from operations
authorMax Kazantsev <max.kazantsev@azul.com>
Fri, 31 Mar 2017 12:05:30 +0000 (12:05 +0000)
committerMax Kazantsev <max.kazantsev@azul.com>
Fri, 31 Mar 2017 12:05:30 +0000 (12:05 +0000)
commit85ae85b8217bc0f5fc613784edf82d9df0434fae
tree996ee13b2e9e93f9e836f084458172c633b0ace7
parent55cd27a031616e1230bb16766881dafb2c4eb6a7
[ScalarEvolution] Re-enable Predicate implication from operations

The patch rL298481 was reverted due to crash on clang-with-lto-ubuntu build.
The reason of the crash was type mismatch between either a or b and RHS in the following situation:

  LHS = sext(a +nsw b) > RHS.

This is quite rare, but still possible situation. Normally we need to cast all {a, b, RHS} to their widest type.
But we try to avoid creation of new SCEV that are not constants to avoid initiating recursive analysis that
can take a lot of time and/or cache a bad value for iterations number. To deal with this, in this patch we
reject this case and will not try to analyze it if the type of sum doesn't match with the type of RHS. In this
situation we don't need to create any non-constant SCEVs.

This patch also adds an assertion to the method IsProvedViaContext so that we could fail on it and not
go further into range analysis etc (because in some situations these analyzes succeed even when the passed
arguments have wrong types, what should not normally happen).

The patch also contains a fix for a problem with too narrow scope of the analysis caused by wrong
usage of predicates in recursive invocations.

The regression test on the said failure: test/Analysis/ScalarEvolution/implied-via-addition.ll

Reviewers: reames, apilipenko, anna, sanjoy

Reviewed By: sanjoy

Subscribers: mzolotukhin, mehdi_amini, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299205 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/ScalarEvolution.h
lib/Analysis/ScalarEvolution.cpp
test/Analysis/ScalarEvolution/implied-via-addition.ll [new file with mode: 0644]
test/Analysis/ScalarEvolution/implied-via-division.ll [new file with mode: 0644]