[PATCH] D156215: [DAGCombiner] Reassociate the operands from (OR (OR(CMP1, CMP2)), CMP3) to (OR (OR(CMP1, CMP3)), CMP2)

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 27 03:17:41 PDT 2023


foad added a comment.

Seems reasonable, but I wonder how often this helps in real code.

Your patch does not handle swapped comparison conditions, e.g. reassociating an expression so that `a<b` can be combined with `b>c`. Doing that properly would make it much more complicated and I don't think it is worth it.

Your patch does not help if there is a tree of ANDs or ORs with //more// than three setcc nodes.



================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1333
+
+    // Reassociate the operands from (OR/AND (OR/AND(N00, N001)), N1) to (OR/AND
+    // (OR/AND(N00, N1)), N01) when N00 and N1 are comparisons with the same
----------------
Typo "N001"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156215



More information about the llvm-commits mailing list