[llvm] [GISel] Funnel shift combiner port from SelectionDAG ISel to GlobalISel (PR #135132)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Tue May 6 04:58:28 PDT 2025
jayfoad wrote:
> I think my confusion stems from what happens when we do `(apply (G_FSHR $root, $z, $x, $y))` vs `(apply (GIReplaceReg $root, $out1))`. This is how I believe it works:
>
> * The first `apply` I mentioned removes all of the instructions that are matched with the resulting instruction in the `apply`
> * The second `apply` I mentioned replaces _only_ the specified instruction, not everything that's matched
The combine doesn't really remove the original instructions, it just replaces all uses of the original root instruction. Then it's up to the normal dead code elimination to remove the original instructions _if_ they are unused. The point of a hasOneUse check is to make sure that one of the sub-instructions in the pattern _will_ be unused, because it doesn't have any other uses outside of the pattern we matched.
Typically for a cmobine that creates a new instruction, you would use hasOneUse checks, because you don't want to create a new instruction unless you can remove one or more of the existing instructions. But this combine does not create any new instructions, so I don't think there's any particular need for tha hasOneUse check.
https://github.com/llvm/llvm-project/pull/135132
More information about the llvm-commits
mailing list