[PATCH] D144284: [X86] Add transform for `(and/or (icmp eq/ne A,-1),(icmp eq/ne A,-1+C))`->`(and/or (icmp eq/ne (and ~A,-1+C),0))`

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 19 22:14:36 PST 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:5948-5954
+        if (MaxC.isAllOnes() &&
+            (TargetPreference & AndOrSETCCFoldKind::NotAnd)) {
+          SDValue NotOp = DAG.getNOT(DL, LHS0, OpVT);
+          SDValue AndOp = DAG.getNode(ISD::AND, DL, OpVT, NotOp,
+                                      DAG.getConstant(MinC, DL, OpVT));
+          return DAG.getNode(ISD::SETCC, DL, VT, AndOp,
+                             DAG.getConstant(0, DL, OpVT), LHS.getOperand(2));
----------------
pengfei wrote:
> The logic here is `NotAnd` always precedes `AddAnd`, why do we need to bother bit or them?
both could be desirable transformations. Its possible for the `AddAnd` pattern to hit, but not the `NotAnd` pattern.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144284



More information about the llvm-commits mailing list