[PATCH] D142535: [DAGCombine] Fold redundant select

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 28 09:51:08 PST 2023


craig.topper added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:10898
+    // both are controlled from the two setcc nodes which cannot produce the
+    // same value, we can fold away N.
+    // select (setcc X), Y, (select (setcc X), Z, Y) -> select (setcc X), Z, Y
----------------
This is phrased as "same value" but I think the checks just check that they can't both be true at the same time. They could still both be false at the same time.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:10919
+      } else {
+        OtherSelect = N2;
+        SelectsShareOp = AreSame(OtherSelect.getOperand(2), N1);
----------------
If we match the second form with select on the false operand, do we need to invert the condition codes to get back to the first form?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142535



More information about the llvm-commits mailing list