1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-24 05:23:45 +02:00
llvm-mirror/lib/Transforms/Scalar
Artur Pilipenko 2bac40ee1c [IndVarSimplify] Use control-dependent range information to prove non-negativity
This change is motivated by the case when IndVarSimplify doesn't widen a comparison of IV increment because it can't prove IV increment being non-negative. We end up with a redundant trunc of the widened increment on this example.

for.body:
  %i = phi i32 [ %start, %for.body.lr.ph ], [ %i.inc, %for.inc ]
  %within_limits = icmp ult i32 %i, 64
  br i1 %within_limits, label %continue, label %for.end

continue:
  %i.i64 = zext i32 %i to i64
  %arrayidx = getelementptr inbounds i32, i32* %base, i64 %i.i64
  %val = load i32, i32* %arrayidx, align 4
  br label %for.inc

for.inc:
  %i.inc = add nsw nuw i32 %i, 1
  %cmp = icmp slt i32 %i.inc, %limit
  br i1 %cmp, label %for.body, label %for.end

There is a range check inside of the loop which guarantees the IV to be non-negative. NSW on the increment guarantees that the increment is also non-negative. Teach IndVarSimplify to use the range check to prove non-negativity of loop increments.

Reviewed By: sanjoy

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

llvm-svn: 284629
2016-10-19 18:59:03 +00:00
..
ADCE.cpp Merge branch 'ADCE5' 2016-09-19 23:17:58 +00:00
AlignmentFromAssumptions.cpp Scalar: Ignore ConstantData in processAssumption 2016-09-24 20:00:38 +00:00
BDCE.cpp
CMakeLists.txt
ConstantHoisting.cpp Use StringRef in Pass/PassManager APIs (NFC) 2016-10-01 02:56:57 +00:00
ConstantProp.cpp
CorrelatedValuePropagation.cpp [CVP] Convert an AShr to a LShr if 1st operand is known to be nonnegative. 2016-10-12 13:41:38 +00:00
DCE.cpp
DeadStoreElimination.cpp limit the number of instructions per block examined by dead store elimination 2016-08-26 16:34:27 +00:00
EarlyCSE.cpp Fix typo in comment, NFC 2016-09-07 01:49:41 +00:00
FlattenCFGPass.cpp
Float2Int.cpp
GuardWidening.cpp
GVN.cpp [GVN] Consistently use division instead of shift. NFCI. 2016-10-18 21:02:27 +00:00
GVNHoist.cpp commit back "GVN-hoist: fix store past load dependence analysis (PR30216, PR30499)" 2016-10-13 01:39:10 +00:00
InductiveRangeCheckElimination.cpp [IRCE] Switch over to LLVM_DUMP_METHOD. NFCI. 2016-08-18 15:55:49 +00:00
IndVarSimplify.cpp [IndVarSimplify] Use control-dependent range information to prove non-negativity 2016-10-19 18:59:03 +00:00
JumpThreading.cpp Jump threading: avoid trying to split edge into landingpad block (PR27840) 2016-10-03 18:18:04 +00:00
LICM.cpp Refactor LICM pass in preparation for LoopSink pass. 2016-10-03 18:52:08 +00:00
LLVMBuild.txt
LoadCombine.cpp Use StringRef in Pass/PassManager APIs (NFC) 2016-10-01 02:56:57 +00:00
LoopDataPrefetch.cpp [LoopDataPrefetch] Port to new streaming API for opt remarks 2016-09-30 00:42:43 +00:00
LoopDeletion.cpp Consistently use LoopAnalysisManager 2016-08-09 00:28:52 +00:00
LoopDistribute.cpp [LoopDistribute] Fix a typo in the pass name. 2016-10-05 00:44:52 +00:00
LoopIdiomRecognize.cpp [LoopIdiomRecognize] Merge two if conditions into one. NFCI. 2016-10-07 18:39:43 +00:00
LoopInstSimplify.cpp Consistently use LoopAnalysisManager 2016-08-09 00:28:52 +00:00
LoopInterchange.cpp [LoopInterchange] Track all dependencies, not just anti dependencies. 2016-09-21 19:16:47 +00:00
LoopLoadElimination.cpp LoopLoadElimination should preserve GlobalsAA. 2016-09-16 17:58:07 +00:00
LoopRerollPass.cpp ADT: Give ilist<T>::reverse_iterator a handle to the current node 2016-08-30 00:13:12 +00:00
LoopRotation.cpp Replace "fallthrough" comments with LLVM_FALLTHROUGH 2016-08-17 05:10:15 +00:00
LoopSimplifyCFG.cpp Consistently use LoopAnalysisManager 2016-08-09 00:28:52 +00:00
LoopStrengthReduce.cpp [LoopStrenghtReduce] Refactoring and addition of a new target cost function. 2016-08-17 13:24:19 +00:00
LoopUnrollPass.cpp Reapply "[LoopUnroll] Use the upper bound of the loop trip count to fullly unroll a loop" 2016-10-12 21:29:38 +00:00
LoopUnswitch.cpp Cleanup : Use metadata preserving API for branch creation 2016-09-03 22:26:11 +00:00
LoopVersioningLICM.cpp [NFC] Loop Versioning for LICM code clean up 2016-10-14 23:00:36 +00:00
LowerAtomic.cpp
LowerExpectIntrinsic.cpp [Profile] handle select instruction in 'expect' lowering 2016-09-02 22:03:40 +00:00
LowerGuardIntrinsic.cpp
MemCpyOptimizer.cpp [MemCpy] Add comments for r279769 2016-08-25 21:03:46 +00:00
MergedLoadStoreMotion.cpp IR: Remove Value::intersectOptionalDataWith, replace all calls with calls to Instruction::andIRFlags. 2016-09-07 23:39:04 +00:00
NaryReassociate.cpp Convert some depth first traversals to depth_first 2016-08-19 22:06:23 +00:00
PartiallyInlineLibCalls.cpp
PlaceSafepoints.cpp
Reassociate.cpp [Reassociate] Add additional debug output. NFC. 2016-08-30 13:58:35 +00:00
Reg2Mem.cpp
RewriteStatepointsForGC.cpp [RS4GC] Fix comment to show TODO. NFC 2016-10-06 13:24:20 +00:00
Scalar.cpp [EarlyCSE] Change C API pass interface for EarlyCSE w/ MemorySSA 2016-09-01 15:07:46 +00:00
Scalarizer.cpp
SCCP.cpp [SCCP] Don't delete side-effecting instructions 2016-08-24 18:10:21 +00:00
SeparateConstOffsetFromGEP.cpp Partially revert 279331, as we modify this instruction in the loop 2016-08-19 22:18:38 +00:00
SimplifyCFGPass.cpp
Sink.cpp
SpeculativeExecution.cpp Use StringRef in Pass/PassManager APIs (NFC) 2016-10-01 02:56:57 +00:00
SROA.cpp Use StringRef in Pass/PassManager APIs (NFC) 2016-10-01 02:56:57 +00:00
StraightLineStrengthReduce.cpp ScalarOpts: Use std::list for Candidates, NFC 2016-09-11 21:29:34 +00:00
StructurizeCFG.cpp Use StringRef in Pass/PassManager APIs (NFC) 2016-10-01 02:56:57 +00:00
TailRecursionElimination.cpp Use the range variant of find/find_if instead of unpacking begin/end 2016-08-12 03:55:06 +00:00