[SCEV] Generalize the SCEV algorithm for creating expressions for PHI nodes
authorSilviu Baranga <silviu.baranga@arm.com>
Fri, 30 Oct 2015 15:02:28 +0000 (15:02 +0000)
committerSilviu Baranga <silviu.baranga@arm.com>
Fri, 30 Oct 2015 15:02:28 +0000 (15:02 +0000)
commit0c35941274e5339100d1520465a4bc0f21fca5bc
tree16562e83370c4601893b9cad381e5bd0d740dbd4
parent7ef85b4579dae5ddf5e318d7d5ae201131401483
[SCEV] Generalize the SCEV algorithm for creating expressions for PHI nodes

Summary:
When forming expressions for phi nodes having an incoming value from
outside the loop A and a value coming from the previous iteration B
we were forming an AddRec if:
  - B was an AddRec
  - the value A was equal to the value for B at iteration -1 (or equal
    to the value of B shifted by one iteration, at iteration 0)

In this case, we were computing the expression to be the expression of
B, shifted by one iteration.

This changes generalizes the logic above by removing the restriction that
B needs to be an AddRec. For this we introduce two expression rewriters
that allow us to
  - shift an expression by one iteration
  - get the value of an expression at iteration 0

This allows us to get SCEV expressions for PHI nodes when these expressions
are not AddRecExprs.

Reviewers: sanjoy

Subscribers: llvm-commits, sanjoy

Differential Revision: http://reviews.llvm.org/D14175

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251700 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/ScalarEvolution.cpp
test/Analysis/ScalarEvolution/non-IV-phi.ll [new file with mode: 0644]