[SCEV] Use backedge SCEV of PHI only if its input is loop invariant
authorDenis Antrushin <dantrushin@gmail.com>
Wed, 22 Jan 2020 13:40:32 +0000 (20:40 +0700)
committerDenis Antrushin <dantrushin@gmail.com>
Tue, 31 Mar 2020 11:39:24 +0000 (18:39 +0700)
commit06c58f11a99a35da5799de8771cafdc47db69a8a
treea35c2f92b173673d035fee1f00fff2a4ed4ecf07
parentb9810988b23c96d1628371868336cb27e2daacca
[SCEV] Use backedge SCEV of PHI only if its input is loop invariant

For the PHI node

      %1 = phi [%A, %entry], [%X, %latch]

it is incorrect to use SCEV of backedge val %X as an exit value
of PHI unless %X is loop invariant.
This is because exit value of %1 is value of %X at one-before-last
iteration of the loop.

Reviewed By: Meinersbur
Differential Revision: https://reviews.llvm.org/D73181
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/ScalarEvolution/pr44605.ll [new file with mode: 0644]