[PATCH] D121147: [x86] try harder to use shift instead of test if it can save some immediate bytes

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 10 13:53:57 PST 2022


spatel added inline comments.


================
Comment at: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:5622
+      // TODO: Extend this to handle i32.
+      if (N0.getOperand(0).hasOneUse() && CmpVT == MVT::i64 &&
+          !isInt<8>(Mask) && onlyUsesZeroFlag(SDValue(Node, 0))) {
----------------
MatzeB wrote:
> I think the `hasOneUse()` check makes sense for the cases where you turning a `testl xx, IMM32` into a shift. However for the IMM64 case we save a whole `movabsq` instruction so even if we end up with an extra COPY its a good deal.
OK, we should add a test for that if it's worth doing. 

I think we should finalize D121320 first since that's the larger patch. Then we can add this as a small enhancement with the appropriate restrictions in place to avoid regressions. This patch is only saving 3 bytes. :)


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

https://reviews.llvm.org/D121147



More information about the llvm-commits mailing list