[IRCE] Fix SCEVExpander's usage in IRCE
authorMax Kazantsev <max.kazantsev@azul.com>
Thu, 16 Nov 2017 06:06:27 +0000 (06:06 +0000)
committerMax Kazantsev <max.kazantsev@azul.com>
Thu, 16 Nov 2017 06:06:27 +0000 (06:06 +0000)
commitb1b8aff2e7b2aa487657a6a13e2cf0bd9d7735d3
treecc9866c2525a56b6c33264ce6ec347efaf76d5bc
parent46a5d58b8c16b7de33dfdf4c86bf7d2b5a7a24fb
[IRCE] Fix SCEVExpander's usage in IRCE

When expanding exit conditions for pre- and postloops, we may end up expanding a
recurrency from the loop to in its loop's preheader. This produces incorrect IR.

This patch ensures that IRCE uses SCEVExpander correctly and only expands code which
is safe to expand in this particular location.

Differentian Revision: https://reviews.llvm.org/D39234

llvm-svn: 318381
llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
llvm/test/Transforms/IRCE/bad_expander.ll [new file with mode: 0644]