[llvm] [WASM] Fold bitselect with splat zero (PR #147305)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 8 00:46:23 PDT 2025


================
@@ -3210,6 +3213,64 @@ static SDValue performTruncateCombine(SDNode *N,
   return truncateVectorWithNARROW(OutVT, In, DL, DAG);
 }
 
+static SDValue performVSelectCombine(SDNode *N, SelectionDAG &DAG) {
+  // In the tablegen.td, vselect A B C -> bitselect B C A
+
+  // SCENARIO A
+  // vselect <0>, X, Y
+  // -> bitselect X, Y, <0>
+  // -> or (AND(X, <0>), AND(<Y>, !<0>))
+  // -> or (0, AND(<Y>, !<0>))
+  // -> AND(Y, !<0>)
+  // -> AND(Y, 1)
+  // -> Y
----------------
lukel97 wrote:

Do we not have a generic combine for this in DAGCombiner already? Is this needed for the two test cases below?

https://github.com/llvm/llvm-project/pull/147305


More information about the llvm-commits mailing list