[PATCH] D25682: [LoopUnroll] Keep the loop test only on the first iteration of max-or-zero loops

John Brawn via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 17 09:09:25 PDT 2016


john.brawn created this revision.
john.brawn added reviewers: sanjoy, christof, haicheng, mzolotukhin.
john.brawn added a subscriber: llvm-commits.
john.brawn set the repository for this revision to rL LLVM.

When we have a loop with a known upper bound on the number of iterations, and furthermore know that either the number of iterations will be either exactly that upper bound or zero, then we can fully unroll up to that upper bound keeping only the first loop test to check for the zero iteration case.

Most of the work here is in plumbing this 'max-or-zero' information from the part of scalar evolution where it's detected through to loop unrolling. I've also gone for the safe default of 'false' everywhere but howManyLessThans which could probably be improved.


Repository:
  rL LLVM

https://reviews.llvm.org/D25682

Files:
  include/llvm/Analysis/ScalarEvolution.h
  include/llvm/Transforms/Utils/UnrollLoop.h
  lib/Analysis/ScalarEvolution.cpp
  lib/Transforms/Scalar/LoopUnrollPass.cpp
  lib/Transforms/Utils/LoopUnroll.cpp
  test/Analysis/ScalarEvolution/trip-count13.ll
  test/Analysis/ScalarEvolution/trip-count14.ll
  test/Transforms/LoopUnroll/full-unroll-keep-first-exit.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25682.74857.patch
Type: text/x-patch
Size: 28857 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161017/cc9bb5fd/attachment.bin>


More information about the llvm-commits mailing list