[PATCH] D24564: [LoopInterchange] Don't bail on flow dependencies when building dependency matrix.

Chad Rosier via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 14 08:18:42 PDT 2016


mcrosier created this revision.
mcrosier added reviewers: karthikthecool, jmolloy, hfinkel.
mcrosier added subscribers: llvm-commits, mssimpso, pekka.jaaskelainen.
Herald added a subscriber: mzolotukhin.

Currently, we give up on loop interchange if we encounter a flow dependency anywhere in the loop list.  However, these dependencies may not actually cause a dependency within the loops we are considering for interchange.

For example,

  static double T[100];
  static int A[1000][1000];

  extern double fn1(void);
  extern void fn2(double);

  void test(int k) {
    for (int k = 0; k < 100; ++k) {
      T[k] = fn1();
      for (int i = 0; i < 1000; ++i)
        for(int j = 1; j < 1000; ++j)
          A[j][i] = A[j][i]+k;
      fn2(T[k]);
    }
  }

The k loop has a flow dependency between 'T[k] = fn1();' and 'fn2(T[k]);'.  However, this shouldn't prevent us from interchanging the i and j loops.

This patch updates the dependency matrix computation to conservatively assume a flow dependency has an unknown dependency, rather than give up on interchange entirely.  The legality analysis then determine if loop interchange is possible.

This improve an internal workload by a 2.2x speedup.  All correctness test pass including SPEC2000, SPEC2006, and the llvm test-suite.

Note the loop interchange pass is off by default.  It can be enabled with '-mllvm -enable-loopinterchange'

Please take a look.

 Chad

https://reviews.llvm.org/D24564

Files:
  lib/Transforms/Scalar/LoopInterchange.cpp
  test/Transforms/LoopInterchange/interchange.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24564.71363.patch
Type: text/x-patch
Size: 7063 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160914/1db8ab23/attachment.bin>


More information about the llvm-commits mailing list