[PATCH] D69497: [PowerPC] Fix MI peephole optimization for splats

Nemanja Ivanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 1 02:46:41 PDT 2019


nemanjai added a comment.

Hmm... sorry to be going back and forth on this a little bit. I am trying to ensure we meet competing goals (simple code, ensure safety and do not overly pessimize the optimization).

I think the semantics should be:

- If `DefReg1 == DefReg2`, this should be safe. Even if they were physical registers, it is not possible for the physical register to have different definitions at one place
- If they are not equal, we look through copies and ensure that the ultimate source is the same virtual register

So it would be good to clearly document the conditions under which we want to do the transformation. Would it work if we changed the early exit to something like:

  // If the two inputs are not the same register, check to see if they originate
  // from the same virtual register after only copy-like instructions.
  if (DefReg1 != DefReg2) {
    unsigned FeedReg1 = TRI->lookThruCopyLike(DefReg1, MRI);
    unsigned FeedReg2 = TRI->lookThruCopyLike(DefReg2, MRI);
    if (FeedReg1 != FeedReg2 || Register::isPhysicalRegister(FeedReg1))
      break;
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69497





More information about the llvm-commits mailing list