[PATCH] D125607: [DAG] Fold (shl (srl x, c), c) -> and(x, m) even if srl has other uses

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 17 05:01:03 PDT 2022


dmgreen accepted this revision.
dmgreen added a comment.
This revision is now accepted and ready to land.

I think AArch64 should be able to do the And efficiently in most cases. There is an instcombine equivalent fold that doesn't check one-use, so from that perspective it will only be things that come up from DAG combine that this alters. I see two win vararg tests changing, with code that comes from AArch64TargetLowering::LowerWindowsDYNAMIC_STACKALLOC.

It seems to be only better because the use happens to be a sub instruction that can include the shift for "free". I'm not sure if that is a great reason, from the architecture perspective, to block the transform (unlike Thumb1 where the And cannot easily be done, as in D55630 <https://reviews.llvm.org/D55630>). But perhaps the shifted instruction is a good enough justification.

I'm not a huge fan of the override for aarch64, but as this is unlikely to come up from IR, it sounds like it should be fine. It is unlikely to be worth trying to implement something that is a more precise for this particular case.

So LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125607



More information about the llvm-commits mailing list