[isl-codegen]: Fix off by one in getNumberOfIterations
authorTobias Grosser <grosser@fim.uni-passau.de>
Mon, 11 Feb 2013 17:52:36 +0000 (17:52 +0000)
committerTobias Grosser <grosser@fim.uni-passau.de>
Mon, 11 Feb 2013 17:52:36 +0000 (17:52 +0000)
commitc92c8f06ec0dcee0bf6cc035bcd3eba34d15cb44
tree4edd15117e1c5c42853062d839db9aed30bca05e
parent0b8ae895b4233da64009ab6fa48f87aada465060
[isl-codegen]: Fix off by one in getNumberOfIterations

We need to remove one dimension. Any is correct as long as it exists. We have
choosen for whatever reason the dimension #dims - 2. This is incorrect if
there is just one dimension. For CLooG this case did never happen. For isl
however, the case can happen and causes undefined behavior including crashes.
We choose now always the last dimension #dims - 1. We could have choosen
dimension '0' but the last dimension is what we remove conceptionally in the
algorithm, so it seems better to actually program it that way.

While at it remove another piece of undefined behavior.

llvm-svn: 174894
polly/include/polly/CodeGen/CodeGeneration.h
polly/test/Isl/CodeGen/20130211-getNumberOfIterations.ll [new file with mode: 0644]