[PATCH] D40369: Support sext, zext and trunc instructions in SCEV delinearization algorithm (new revision)

Alex Susu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 22 11:06:18 PST 2017


alexsusu created this revision.
Herald added a subscriber: sanjoy.
Herald added a reviewer: bollu.

  Extending the patch from https://reviews.llvm.org/D35478 in order to make it work well for SCEVDivision.
  Before the patch, SCEVDivision::divide() was not working due to casts (Trunc, ZExt, SExt). This was manifesting for example when used in the delinearization algorithm of Polly, implemented in ScopDetection.cpp (note that ScalarEvolution.cpp seems to have a delinearize() method also which is an appendix), which needs to perform SCEV division.
  
  Delinearization does (see paper Grosser et al, "On recovering Multi-dimensional Arrays in Polly", IMPACT 2015, Section 4 - http://impact.gforge.inria.fr/impact2015/papers/impact2015-grosser.pdf ):
      - sum of product expansion
      - after a simple removal process, products are sorted by the number of factors
      - check that the smaller terms in the sorted array divide the larger ones
      - symbolically divide the original offset expression by the size of the individual array dimensions starting from the innermost dimension .
  Note that I did not check to see if the sum of product expansion gives in certain corner cases errors due to ScalarEvolution.
  
  However, even the initial patch (from  https://reviews.llvm.org/D35478) had "bugs" - it was not working because it was not treating the Nominator.
  Therefore, we are now treating it for cast expressions. Note that SCEVDivision is a SCEVVisitor - see http://llvm.org/doxygen/ScalarEvolutionExpressions_8h_source.html#l00445: we see that we only need to treat it for Trunc, ZExt, SExt - methods visitTruncateExpr(), visitZeroExtendExpr(), visitSignExtendExpr().
  We also had to adapt numberOfTerms() to treat for cast expressions.
  
  Also, I took liberty to change 2 variable names, consistently in the entire CPP file:
    Nominator --> Dividend
    Denominator --> Divisor


https://reviews.llvm.org/D40369

Files:
  ScalarEvolution.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40369.123979.patch
Type: text/x-patch
Size: 19598 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171122/9e8169e4/attachment.bin>


More information about the llvm-commits mailing list