[llvm] [WebAssembly] Handle wide mask reductions in performSETCCCombine (PR #189358)
Demetrius Kanios via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 1 00:03:41 PDT 2026
================
@@ -3452,6 +3431,124 @@ static SDValue TryMatchTrue(SDNode *N, EVT VecVT, SelectionDAG &DAG) {
return DAG.getZExtOrTrunc(Ret, DL, N->getValueType(0));
}
+enum class MaskReduceKind {
+ AnyTrue,
+ AllTrue,
+};
+
+struct MaskReduceInfo {
+ MaskReduceKind Kind;
+ bool Invert;
+};
+
+static SDValue combineSmallMaskReduction(SDNode *N, EVT FromVT,
+ unsigned NumElts,
+ const MaskReduceInfo &Info,
+ SelectionDAG &DAG) {
+ EVT VecVT = FromVT.changeVectorElementType(*DAG.getContext(),
+ MVT::getIntegerVT(128 / NumElts));
+
+ switch (Info.Kind) {
+ case MaskReduceKind::AnyTrue:
+ if (!Info.Invert)
+ return TryMatchTrue<0, ISD::SETNE, false, Intrinsic::wasm_anytrue>(
+ N, VecVT, DAG);
+ return TryMatchTrue<0, ISD::SETEQ, true, Intrinsic::wasm_anytrue>(N, VecVT,
----------------
QuantumSegfault wrote:
Not necessarily a good idea, but you could collapse the if into the parameters.
```suggestion
return TryMatchTrue<0, Info.Invert ? ISD::SETEQ : ISD::SETNE, Info.Invert, Intrinsic::wasm_anytrue>(N, VecVT,
```
https://github.com/llvm/llvm-project/pull/189358
More information about the llvm-commits
mailing list