[PATCH] D124930: [DagCombine] Fold (X & ~Y) | Y with truncated not

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 5 01:10:37 PDT 2022


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

LGTM



================
Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:4688
 // Only bits set in Mask must be negated, other bits may be arbitrary.
-static SDValue getBitwiseNotOperand(SDValue V, SDValue Mask) {
-  if (isBitwiseNot(V, true))
+SDValue llvm::getBitwiseNotOperand(SDValue V, SDValue Mask, bool AllowUndefs) {
+  if (isBitwiseNot(V, AllowUndefs))
----------------
nikic wrote:
> RKSimon wrote:
> > Would this be more generally useful if we replaced Mask with a APInt DemandedBits?
> Yes -- though it would make the current callers, which all have the mask as an SDValue, more complicated. Would have to extract the isConstOrConstSplat part plus a fallback to an all-ones mask to each caller. I'd personally delay that until we have a use-case that requires passing an APInt.
OK - that's fine, there might be a couple of cases in SimplifyDemandedBits, but we can handle that if/when its useful to convert them to use this.


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

https://reviews.llvm.org/D124930



More information about the llvm-commits mailing list