[PATCH] D137212: [InstCombine] Simplify chain of GEP with constant indices

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 2 11:22:21 PDT 2022


davidxl added a comment.

This is essentially forward propagation (with multi-use) and is a generally a good way to reduce dependence height. For instance it can be used to enable reassociation and LICM:

for (k = .... ;k++) {

  for (i = ....  ; i++) {
  
        b = (a+i);
        call(b);
        y = b + k + x;
      }

}

>
-

for (k = .... ;k++) {

  for (i = ....  ; i++) {
  
        b = (a+i);
        call(b);
        y  = (a + i) + k + x;
      }

}

>
-

for (k = .... ;k++) {

  for (i = ....  ; i++) {
  
        b = (a+i);
        call(b);
        y  = (a + k) + i + x;
      }

}

>
-

for (k = .... ;k++) {

  tmp = a + k;
  for (i = ....  ; i++) {
        b = (a+i);
        call(b);
        y  = tmp + k + x;
      }

}


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137212/new/

https://reviews.llvm.org/D137212



More information about the llvm-commits mailing list