[PATCH] Break dependencies in large loops containing reductions (LoopVectorize)

Olivier Sallenave ohsallen at us.ibm.com
Tue Feb 10 12:30:15 PST 2015


Hi Michael,

> Probably I miss somethings, but what dependencies would unrolling of the outer loop break?


It would break the dependencies between the reduction operations. With the example below, we can dispatch twice more instructions (if target permits), which is profitable to exploit more ILP.

  // Original loop.
  for (int i = 0; i < n; i++) 
      for (int j = 0; j < 3; j++)
          r += arr[i][j];
  
  // After unrolling innermost loop.
  for (int i = 0; i < n; i++)  {
      r += arr[i][0];
      r += arr[i][1];
      r += arr[i][2];
  }
  
  // After unrolling outermost loop (in vectorizer, which breaks dependencies).
  for (int i = 0; i < n; i += 2)  {
      r += arr[i][0];
      r_0 += arr[i+1][0];
      r += arr[i][1];
      r_0 += arr[i+1][1];
      r += arr[i][2];
      r_0 += arr[i+1][2];
  }
  r += r_0;


http://reviews.llvm.org/D7514

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list