[PATCH] D107219: [LICM] Support sinking in LNICM

Whitney Tsang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 4 10:47:03 PDT 2021


Whitney added inline comments.


================
Comment at: llvm/test/Transforms/LICM/lnicm-sink.ll:15
+;     }
+;     y[i] = s;
+;   }
----------------
uint256_t wrote:
> uint256_t wrote:
> > Whitney wrote:
> > > uint256_t wrote:
> > > > Whitney wrote:
> > > > > uint256_t wrote:
> > > > > > Whitney wrote:
> > > > > > > Why `y[i] = s;` is needed for this test case?
> > > > > > It is to show that LNICM maintains perfect loop nest.
> > > > > > LICM sinks `s = abs(i);` to right before `y[i] = s;`, whereas LNICM doesn't do so.
> > > > > Why wouldn't LICM sink `s = abs(i);` without `y[i] = s;`?
> > > > LICM would hoist (not sink) `s = abs(i);` out of loop-j.
> > > how about 
> > > ```
> > > ;   for (int i = 0; i < 10; i++) {
> > > ;     for (int j = 0; j < 10; j++) {
> > > ;       t = sin(x);
> > > ;       s = abs(i);
> > > ;     }
> > > ;   }
> > > ;  return t + s;
> > > ```
> > > ?
> > Oh, it is way better. I'll edit this test case. Thank you.
> > how about 
> > ```
> > ;   for (int i = 0; i < 10; i++) {
> > ;     for (int j = 0; j < 10; j++) {
> > ;       t = sin(x);
> > ;       s = abs(i);
> > ;     }
> > ;   }
> > ;  return t + s;
> > ```
> > ?
> 
> I ran the test case you suggested above, but LICM didn't do what we want... 
> LICM transformed it into something like this:
> 
> ```
> ;  int i, j;
> ;  for (i = 0; i < 10; i++) {
> ;    for (j = 0; j < 10; j++) {
> ;    }
> ;  }
> ;  t = sin(x);
> ;  s = abs(i);
> ;  return t + s;
> ```
> 
> I should make another better test case.
I now see the point of `y[i] = s;`, let's see if you can make a better test case, if not, this is ok with me.


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

https://reviews.llvm.org/D107219



More information about the llvm-commits mailing list