[llvm] [LLVM] Add `llvm.masked.compress` intrinsic (PR #92289)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 19 02:41:49 PDT 2024


================
@@ -12078,6 +12080,68 @@ SDValue DAGCombiner::visitVP_STRIDED_STORE(SDNode *N) {
   return SDValue();
 }
 
+SDValue DAGCombiner::visitMASKED_COMPRESS(SDNode *N) {
+  SDLoc DL(N);
+  SDValue Vec = N->getOperand(0);
+  SDValue Mask = N->getOperand(1);
+  SDValue Passthru = N->getOperand(2);
+  EVT VecVT = Vec.getValueType();
+
+  bool HasPassthru = !Passthru.isUndef();
+
+  APInt SplatVal;
+  if (ISD::isConstantSplatVector(Mask.getNode(), SplatVal)) {
+    bool HasTrueBoolContent = [&] {
+      switch (TLI.getBooleanContents(Mask.getValueType())) {
+      case TargetLoweringBase::UndefinedBooleanContent:
+        return SplatVal.isOne();
+      case TargetLoweringBase::ZeroOrOneBooleanContent:
+        return SplatVal.isOneBitSet(0);
+      case TargetLoweringBase::ZeroOrNegativeOneBooleanContent:
+        return SplatVal.isAllOnes();
+      }
+    }();
+
+    return HasTrueBoolContent ? Vec
----------------
RKSimon wrote:

I think you can use TLI.isConstTrueVal for this

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


More information about the llvm-commits mailing list