[LoopPeeling] Fix condition for phi-eliminating peeling
authorMax Kazantsev <max.kazantsev@azul.com>
Mon, 17 Apr 2017 05:38:28 +0000 (05:38 +0000)
committerMax Kazantsev <max.kazantsev@azul.com>
Mon, 17 Apr 2017 05:38:28 +0000 (05:38 +0000)
commit8ed6b66d853cbdb13ab838bcb47ea6feb94c09f3
tree5ad4218fb70a7501a7c0986bf8484c0b448ba3fd
parent2616bbb16d8a2ba0817b846fb3fc354f6f511260
[LoopPeeling] Fix condition for phi-eliminating peeling

When peeling loops basing on phis becoming invariants, we make a wrong loop size check.
UP.Threshold should be compared against the total numbers of instructions after the transformation,
which is equal to 2 * LoopSize in case of peeling one iteration.
We should also check that the maximum allowed number of peeled iterations is not zero.

Reviewers: sanjoy, anna, reames, mkuper

Reviewed By: mkuper

Subscribers: llvm-commits

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

llvm-svn: 300441
llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp
llvm/test/Transforms/LoopUnroll/peel-loop-negative.ll [new file with mode: 0644]
llvm/test/Transforms/LoopUnroll/peel-loop-not-forced.ll