[IRCE] Use SCEVExpander to modify loop bound
authorDenis Antrushin <dantrushin@gmail.com>
Mon, 27 Jan 2020 19:06:02 +0000 (22:06 +0300)
committerDenis Antrushin <dantrushin@gmail.com>
Thu, 6 Feb 2020 09:44:43 +0000 (12:44 +0300)
commit99a6e405edbfc4eb54af5fe7804f47aae139ce53
tree0cffd238d4f78c6b5e283cd69c3f9465fa8ea2dc
parent5c3b34930c31227b5f33f1886d13431c4c90a1b0
[IRCE] Use SCEVExpander to modify loop bound

IRCE pass checks that it can calculate loop bounds by checking
SCEV availability at loop entry. However it is possible that loop
bound SCEV is loop invariant, but instruction used to compute it
resides within loop. In such case adjusting loop bound in preheader
using IRBuilder leads to malformed SSA.
Use SCEVExpander instead to generate proper instructions.

Reviewed-by: mkazantsev
Differential Revision: https://reviews.llvm.org/D73496
llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
llvm/test/Transforms/IRCE/non-loop-invariant-rhs-instr.ll [new file with mode: 0644]