[PATCH] [LoopInterchange] Add support to interchange loops with reductions.

Karthik Bhat kv.bhat at samsung.com
Fri Mar 13 02:50:20 PDT 2015


Hi hfinkel, jmolloy,

Hi Hal,
Please find attached the patch to enable interchange of loops having reductions. The logic to detect a reduction/induction is borrowed from loop vectorizer code. 

With this change we are now able to interchange matrix multiplication code such as one below-
  for( int i=1;i<2048;i++)
    for( int j=1;j<2048;j++)
      for( int k=1;k<2048;k++) 
        A[i][j]+=B[i][k]*C[k][j];
into -
  for( int k=1;k<2048;k++) 
    for( int i=1;i<2048;i++)
      for( int j=1;j<2048;j++)
        A[i][j]+=B[i][k]*C[k][j];
which now gets vectorized. 

We observe a ~3X execution time improvement in the above code.
Please if you could let me know your inputs on the same.

Thanks and Regards
Karthik Bhat

http://reviews.llvm.org/D8314

Files:
  lib/Transforms/IPO/PassManagerBuilder.cpp
  lib/Transforms/Scalar/LoopInterchange.cpp
  test/Transforms/LoopInterchange/reductions.ll

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8314.21907.patch
Type: text/x-patch
Size: 41975 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150313/d3116cf4/attachment.bin>


More information about the llvm-commits mailing list