[llvm] [LLVM] Add `llvm.masked.compress` intrinsic (PR #92289)
    Simon Pilgrim via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Wed Jun 19 05:08:21 PDT 2024
    
    
  
================
@@ -12078,6 +12080,57 @@ 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)) {
+    return TLI.isConstTrueVal(Mask)
+               ? Vec
+               : (HasPassthru ? Passthru : DAG.getUNDEF(VecVT));
----------------
RKSimon wrote:
`return TLI.isConstTrueVal(Mask) ? Vec : Passthru;` - I'm not sure if you gain anything from recreating the UNDEF now
https://github.com/llvm/llvm-project/pull/92289
    
    
More information about the llvm-commits
mailing list