[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:09:37 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);
----------------
barannikov88 wrote:
> 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.
>
I messed up operands of isSubRegisterEq. It should read:
"if `isSubRegisterEq(CopyDstReg, MOUse.getReg())` returns true, i.e. if `MOUse.getReg()` is the same as `CopyDstReg` or is a sub-register of `CopyDstReg`."
```
renamable $d14 = COPY killed $d15
$s0 = COPY killed renamable $s28
```
Here, $d14 is `CopyDstReg`, $s28 is `MOUse.getReg()`, and $d15 is `CopySrcReg`.
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