[PATCH] D146930: [MCP] Do not try forward non-existent sub-register of a copy

Sergei Barannikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 27 21:03:47 PDT 2023


barannikov88 added inline comments.


================
Comment at: llvm/lib/CodeGen/MachineCopyPropagation.cpp:651
+      unsigned SubRegIdx = TRI->getSubRegIndex(CopyDstReg, MOUse.getReg());
+      assert(SubRegIdx && "findAvailCopy returned unrelated instruction");
+      ForwardedReg = TRI->getSubReg(CopySrcReg, SubRegIdx);
----------------
arsenm wrote:
> Don't really understand the assert message here (plus I thought getSubRegIndex could deal with the 0 case anyway)
`findAvailCopy` returns non-null only if `isSubRegisterEq(CopyDstReg, MOUse.getReg())` returns true, i.e. if `CopyDstReg` is the same as `MOUse.getReg()` or is a sub-register of `MOUse.getReg()`. If it is a sub-register, it must have a valid sub-register index, and this is checked by this assertion.
Could you suggest how to rephrase the assert message? My English is bad at times.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146930



More information about the llvm-commits mailing list