llvm-project/llvm/lib/Transforms/Scalar
Sanjoy Das a1837a342d Add a new pass "inductive range check elimination"
IRCE eliminates range checks of the form

  0 <= A * I + B < Length

by splitting a loop's iteration space into three segments in a way
that the check is completely redundant in the middle segment.  As an
example, IRCE 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();
    }
  }


IRCE can deal with multiple range checks in the same loop (it takes
the intersection of the ranges that will make each of them redundant
individually).

Currently IRCE does not do any profitability analysis.  That is a
TODO.

Please note that the status of this pass is *experimental*, and it is
not part of any default pass pipeline.  Having said that, I will love
to get feedback and general input from people interested in trying
this out.

This pass was originally r226201.  It was reverted because it used C++
features not supported by MSVC 2012.

Differential Revision: http://reviews.llvm.org/D6693

llvm-svn: 226238
2015-01-16 01:03:22 +00:00
..
ADCE.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
AlignmentFromAssumptions.cpp [PM] Split the AssumptionTracker immutable pass into two separate APIs: 2015-01-04 12:03:27 +00:00
CMakeLists.txt Add a new pass "inductive range check elimination" 2015-01-16 01:03:22 +00:00
ConstantHoisting.cpp Remove unnecessary copying or replace it with moves in a bunch of places. 2014-10-04 16:55:56 +00:00
ConstantProp.cpp [PM] Separate the TargetLibraryInfo object from the immutable pass. 2015-01-15 10:41:28 +00:00
CorrelatedValuePropagation.cpp Make use of @llvm.assume from LazyValueInfo 2014-09-07 20:29:59 +00:00
DCE.cpp [PM] Separate the TargetLibraryInfo object from the immutable pass. 2015-01-15 10:41:28 +00:00
DeadStoreElimination.cpp [PM] Move TargetLibraryInfo into the Analysis library. 2015-01-15 02:16:27 +00:00
EarlyCSE.cpp [PM] Separate the TargetLibraryInfo object from the immutable pass. 2015-01-15 10:41:28 +00:00
FlattenCFGPass.cpp [Modules] Fix potential ODR violations by sinking the DEBUG_TYPE 2014-04-22 02:55:47 +00:00
GVN.cpp [PM] Separate the TargetLibraryInfo object from the immutable pass. 2015-01-15 10:41:28 +00:00
IndVarSimplify.cpp [PM] Separate the TargetLibraryInfo object from the immutable pass. 2015-01-15 10:41:28 +00:00
InductiveRangeCheckElimination.cpp Add a new pass "inductive range check elimination" 2015-01-16 01:03:22 +00:00
JumpThreading.cpp [PM] Separate the TargetLibraryInfo object from the immutable pass. 2015-01-15 10:41:28 +00:00
LICM.cpp [PM] Separate the TargetLibraryInfo object from the immutable pass. 2015-01-15 10:41:28 +00:00
LLVMBuild.txt Update libdeps since TLI was moved from Target to Analysis in r226078. 2015-01-15 05:21:00 +00:00
LoadCombine.cpp Use AA in LoadCombine 2014-11-03 23:19:16 +00:00
LoopDeletion.cpp Use range based for loops to avoid needing to re-mention SmallPtrSet size. 2014-08-24 23:23:06 +00:00
LoopIdiomRecognize.cpp [PM] Separate the TargetLibraryInfo object from the immutable pass. 2015-01-15 10:41:28 +00:00
LoopInstSimplify.cpp [PM] Separate the TargetLibraryInfo object from the immutable pass. 2015-01-15 10:41:28 +00:00
LoopRerollPass.cpp [PM] Separate the TargetLibraryInfo object from the immutable pass. 2015-01-15 10:41:28 +00:00
LoopRotation.cpp [PM] Split the AssumptionTracker immutable pass into two separate APIs: 2015-01-04 12:03:27 +00:00
LoopStrengthReduce.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
LoopUnrollPass.cpp [LoopUnroll] Fix the partial unrolling threshold for small loop sizes 2015-01-10 00:30:55 +00:00
LoopUnswitch.cpp [PM] Split the AssumptionTracker immutable pass into two separate APIs: 2015-01-04 12:03:27 +00:00
LowerAtomic.cpp IR: add "cmpxchg weak" variant to support permitted failure. 2014-06-13 14:24:07 +00:00
Makefile
MemCpyOptimizer.cpp [PM] Separate the TargetLibraryInfo object from the immutable pass. 2015-01-15 10:41:28 +00:00
MergedLoadStoreMotion.cpp [PM] Separate the TargetLibraryInfo object from the immutable pass. 2015-01-15 10:41:28 +00:00
PartiallyInlineLibCalls.cpp [PM] Separate the TargetLibraryInfo object from the immutable pass. 2015-01-15 10:41:28 +00:00
Reassociate.cpp [Reassociate] Use dbgs() instead of errs(). 2014-12-12 14:44:12 +00:00
Reg2Mem.cpp Standardize {pred,succ,use,user}_empty() 2015-01-13 03:46:47 +00:00
SCCP.cpp [PM] Separate the TargetLibraryInfo object from the immutable pass. 2015-01-15 10:41:28 +00:00
SROA.cpp Revert "Reapply: Teach SROA how to update debug info for fragmented variables." 2015-01-08 02:02:00 +00:00
SampleProfile.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
Scalar.cpp Add a new pass "inductive range check elimination" 2015-01-16 01:03:22 +00:00
ScalarReplAggregates.cpp [PM] Split the AssumptionTracker immutable pass into two separate APIs: 2015-01-04 12:03:27 +00:00
Scalarizer.cpp Revert "IR: MDNode => Value" 2014-11-11 21:30:22 +00:00
SeparateConstOffsetFromGEP.cpp [SeparateConstOffsetFromGEP] Allow SeparateConstOffsetFromGEP pass to lower GEPs. 2014-11-19 06:24:44 +00:00
SimplifyCFGPass.cpp [PM] Split the AssumptionTracker immutable pass into two separate APIs: 2015-01-04 12:03:27 +00:00
Sink.cpp Use range based for loops to avoid needing to re-mention SmallPtrSet size. 2014-08-24 23:23:06 +00:00
StructurizeCFG.cpp StructurizeCFG: Use LoopInfo analysis for better loop detection 2014-12-03 04:28:32 +00:00
TailRecursionElimination.cpp Fix tail recursion elimination 2014-11-19 13:32:51 +00:00