]> granicus.if.org Git - llvm/commit
[IRCE] Add a missing invariant check
authorSanjoy Das <sanjoy@playingwithpointers.com>
Tue, 7 Feb 2017 23:59:07 +0000 (23:59 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Tue, 7 Feb 2017 23:59:07 +0000 (23:59 +0000)
commit541d77cf0d2bd08fbc51ca6221f8833e44dae99c
tree3b703d397a152f67bf652b28e037a49d0d52579c
parent3aa9ab7ce6a52f33e4f3403aa58dd6b8f77811ab
[IRCE] Add a missing invariant check

Currently IRCE relies on the loops it transforms to be (semantically) of
the form:

  for (i = START; i < END; i++)
    ...

or

  for (i = START; i > END; i--)
    ...

However, we were not verifying the presence of the START < END entry
check (i.e. check before the first iteration).  We were only verifying
that the backedge was guarded by (i + 1) < END.

Usually this would work "fine" since (especially in Java) most loops do
actually have the START < END check, but of course that is not
guaranteed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294375 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
test/Transforms/IRCE/bad-loop-structure.ll [new file with mode: 0644]