[PATCH] D118635: [GlobalISel] Combine: (G_*MULO x, 0) -> 0 + no carry out
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 4 00:19:39 PST 2022
foad added inline comments.
================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:4589
+ MatchInfo = [=](MachineIRBuilder &B) {
+ B.buildConstant(Dst, 0);
+ B.buildConstant(Carry, 0);
----------------
Can't you copy from the RHS of the mul here? And hence there should be no need to check legality for this constant?
================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:4590
+ B.buildConstant(Dst, 0);
+ B.buildConstant(Carry, 0);
+ };
----------------
paquette wrote:
> foad wrote:
> > How does this work? Don't you need to build a single instruction that has two results (just like G_*MULO)?
> I don't think it matters; although G_*MULO instructions produce two results, those results are just regular vregs. As long as they are still defined, the uses should work out.
>
> So, we should be able to replace this with two instructions if we know what the results are going to be. In the case of
>
> ```
> %mul, %o = G_*MULO %x, <zero>
> ```
>
> We know that the value of `%mul` and `%o` must both be 0. So replacing them both with appropriately-sized 0s ought to be safe.
Oh yeah, sorry. I was forgetting that (unlike sdag) it is just writing to two vregs.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118635/new/
https://reviews.llvm.org/D118635
More information about the llvm-commits
mailing list