[llvm] [WebAssembly] [Backend] Wasm optimize illegal bitmask (PR #145627)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 30 02:18:35 PDT 2025


================
@@ -3214,20 +3216,26 @@ static SDValue performTruncateCombine(SDNode *N,
 
 static SDValue performBitcastCombine(SDNode *N,
                                      TargetLowering::DAGCombinerInfo &DCI) {
+  using namespace llvm::SDPatternMatch;
   auto &DAG = DCI.DAG;
   SDLoc DL(N);
   SDValue Src = N->getOperand(0);
   EVT VT = N->getValueType(0);
   EVT SrcVT = Src.getValueType();
 
-  // bitcast <N x i1> to iN
+  bool Vectorizable = DCI.isBeforeLegalize() && VT.isScalarInteger() &&
+                      SrcVT.isFixedLengthVector() &&
+                      SrcVT.getScalarType() == MVT::i1;
+
+  if (!Vectorizable)
+    return SDValue();
----------------
lukel97 wrote:

Nit, this is somewhat the opposite of vectorizing right where it's turning a vector into a scalar?
I would just remove the variable and stick all the checks in the if statement, clang-format should make it readable enough

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


More information about the llvm-commits mailing list