[PATCH] D62871: [Codegen] (X & (C l>>/<< Y)) ==/!= 0 --> ((X <</l>> Y) & C) ==/!= 0 fold

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 24 14:50:07 PDT 2019


lebedev.ri marked 2 inline comments as done.
lebedev.ri added inline comments.


================
Comment at: include/llvm/CodeGen/TargetLowering.h:538
+  /// Return true if the target has a bit-test instruction:
+  ///   (X & (1 << Y)) ==/!= 0
+  virtual bool hasBitTest(SDValue X, SDValue Y) const { return false; }
----------------
efriedma wrote:
> Maybe worth clarifying here that the point of this hook is to prevent DAGCombine from breaking the pattern?
Or creating it if it has potential of being recognized, will add.


================
Comment at: include/llvm/CodeGen/TargetLowering.h:579
+  virtual bool shouldProduceAndByConstByHoistingConstFromShiftsLHSOfAnd(
+      SDValue X, ConstantSDNode *XC, ConstantSDNode *CC, SDValue Y,
+      unsigned OldShiftOpcode, unsigned NewShiftOpcode,
----------------
spatel wrote:
> Is there some reason to send XC in as a parameter rather than asking if it is a constant within this function and giving that constant a local name?
I'm pretty sure i have tried that.
As far as i recall, i can't do that because `isConstOrConstSplat()` is defined in `DAGCombine.cpp`,
which isn't guaranteed to be linked in every library where this hook could end up.



Repository:
  rL LLVM

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

https://reviews.llvm.org/D62871





More information about the llvm-commits mailing list