[PATCH] D35264: [LICM] Teach LICM to hoist conditional loads

Michael Kuperstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 11 11:23:47 PDT 2017


mkuper requested changes to this revision.
mkuper added a comment.
This revision now requires changes to proceed.

This looks wrong.
In particular, it would break for something like:

  a = *p;
  free(p)
  while (k) { // k is always false
   ... = *p;
  }

We have llvm::isSafeToLoadUnconditionally() that does the domination check safely, but just checking that it's safe to load unconditionally in the pre-header may not be enough.

Consider something like:

  a = *p;
  while (k) {
    if (m) {
      free(p);
    }
    ... = *p;
  
  }

Now, in those cases we shouldn't be hoisting regardless, because if p escapes, the value may not be loop-invariant.
But we need to make sure the patch doesn't break that, so additional tests may be needed.


Repository:
  rL LLVM

https://reviews.llvm.org/D35264





More information about the llvm-commits mailing list