[llvm-dev] Loop Strength Reduction Pass Does Not Work for Some Varialbles Related to Induction Variables

Tingyuan LIANG via llvm-dev llvm-dev at lists.llvm.org
Mon Apr 15 09:52:59 PDT 2019

Dear all,

    Hi! Recently, I try to combine the passes SeparateConstOffsetFromGEP and  LoopStrengthReduction to transform the multiplication in the lowered GEP IRs into addition.
    However, it seems LoopStrengthReduction is unable to remove all the multiplications for the element offset calculation.
    My test code is shown below and thanks a lot in advance for your time and suggestion!
#define NI 16
#define NJ 18
#define NK 22
#define NL 24
void kernel_2mm(int ni, int nj, int nk, int nl,
    int alpha,
    int beta,
    int tmp[NI][NJ],
    int A[NI][NK],
    int B[NK][NJ],
    int C[NJ][NL],
    int D[NI][NL])
  int i, j, k;

  /* D := alpha*A*B*C + beta*D */
  for (i = 0; i < NI; i++)
    for (j = 0; j < NJ; j++)
        tmp[i][j] = 0;
        for (k = 0; k < NK; ++k)
          tmp[i][j] += alpha * A[i][k] * B[k][j];
    for (i = 0; i < NI; i++)
      for (j = 0; j < NL; j++)
        D[i][j] *= beta;
          for (k = 0; k < NJ; ++k)
            D[i][j] += tmp[i][k] * C[k][j];

Best regards,
Tingyuan LIANG
MPhil Student
Department of Electronic and Computer Engineering
The Hong Kong University of Science and Technology
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190415/c1ffa43b/attachment-0001.html>

More information about the llvm-dev mailing list