[llvm] [SelectionDAG] Fold (avg x, 0) -> x >> 1 (PR #85581)
    via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Mar 18 09:03:23 PDT 2024
    
    
  
================
@@ -5083,7 +5083,18 @@ SDValue DAGCombiner::visitAVG(SDNode *N) {
   if (N0 == N1 && Level >= AfterLegalizeTypes)
     return N0;
 
-  // TODO If we use avg for scalars anywhere, we can add (avgfl x, 0) -> x >> 1
+  // Fold (avg x, 0) -> x >> 1
+  if (isNullOrNullSplat(N0))
----------------
AtariDreams wrote:
I am not at all changing how vectors with undefs are handled. I am only changing how zero constants/vectors are handled.
https://github.com/llvm/llvm-project/pull/85581
    
    
More information about the llvm-commits
mailing list