1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-23 21:13:02 +02:00
llvm-mirror/lib/Transforms
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
..
Coroutines [coroutines] Store an address of destroy OR cleanup part in the coroutine frame. 2016-10-08 00:22:50 +00:00
Hello Add auto-exporting of symbols from tools so that plugins work on Windows 2016-05-26 11:16:43 +00:00
InstCombine [InstCombine] use m_APInt to allow sub with constant folds for splat vectors 2016-10-14 16:31:54 +00:00
Instrumentation [asan] Simplify calculation of stack frame layout extraction calculation of stack description into separate function. 2016-10-18 23:29:52 +00:00
IPO Conditionally eliminate library calls where the result value is not used 2016-10-18 21:36:27 +00:00
ObjCARC Use StringRef in ARCRuntimeEntryPoints APIs (NFC) 2016-10-05 01:15:04 +00:00
Scalar [IndVarSimplify] Use control-dependent range information to prove non-negativity 2016-10-19 18:59:03 +00:00
Utils [asan] Replace std::to_string with llvm::to_string 2016-10-19 00:16:56 +00:00
Vectorize [LV] Account for predicated stores in instruction costs 2016-10-13 14:54:31 +00:00
CMakeLists.txt [coroutines] Part 3 of N: Adding Boilerplate for Coroutine Passes 2016-07-28 21:04:31 +00:00
LLVMBuild.txt [coroutines] Part 3 of N: Adding Boilerplate for Coroutine Passes 2016-07-28 21:04:31 +00:00