[PATCH] D144789: [DAG] Match select(icmp(x,y),sub(x,y),sub(y,x)) -> abd(x,y) patterns

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 26 02:27:16 PST 2023


RKSimon added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:11807
+        N1.getOperand(0) == N2.getOperand(1) && 
+        N1.getOperand(1) == N2.getOperand(0)) {
+      bool IsSigned = isSignedIntSetCC(CC);
----------------
goldstein.w.n wrote:
> Maybe there should be one-use checks? Is `abd` more efficient if the sub operations are already needed?
X86 is probably the worst case for this as it usually folds to sub(max(x,y),min(x,y)) - most other cases currently have a ABD instruction, or would gain from better ILP (see PPC's ABDS v4i32 variant).

I'll add more extensive x86 test coverage and see what it looks like.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144789



More information about the llvm-commits mailing list