[PATCH] New pass: inductive range check elimination
Sanjoy Das
sanjoy at playingwithpointers.com
Tue Dec 16 14:15:44 PST 2014
Hi reames, atrick, hfinkel,
The inductive range check elimination pass eliminates range checks from within loops by splitting the iteration space into three segments in a way that the range check is fully redundant in one of the segments. As an example, it will convert
len = < known positive >
for (i = 0; i < n; i++) {
if (0 <= i && i < len) {
do_something();
} else {
throw_out_of_bounds();
}
}
to
len = < known positive >
limit = smin(n, len)
// no first segment
for (i = 0; i < limit; i++) {
if (0 <= i && i < len) { // this check is fully redundant
do_something();
} else {
throw_out_of_bounds();
}
}
for (i = limit; i < n; i++) {
if (0 <= i && i < len) {
do_something();
} else {
throw_out_of_bounds();
}
}
This is very close to the now removed LoopIndexSplit pass in spirit.
I believe the pass is correct (i.e. running it should not change the meaning of the program) but there still remains a considerable amount of work left to make it actually effective. I'd like to do as much of that work as possible in-tree.
http://reviews.llvm.org/D6693
Files:
include/llvm/InitializePasses.h
include/llvm/LinkAllPasses.h
include/llvm/Transforms/Scalar.h
lib/Transforms/Scalar/CMakeLists.txt
lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
lib/Transforms/Scalar/Scalar.cpp
test/Transforms/InductiveRangeCheckElimination/single.ll
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6693.17362.patch
Type: text/x-patch
Size: 39438 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141216/f3937731/attachment.bin>
More information about the llvm-commits
mailing list