[llvm] [SelectionDAG] Fold (avg x, 0) -> x >> 1 (PR #85581)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 18 21:17:45 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))
----------------
topperc wrote:
If you pass allow undefs to `isNullOrNullSplat`, can we remove the `ISD::isConstantSplatVectorAllZeros` version of the code?
https://github.com/llvm/llvm-project/pull/85581
More information about the llvm-commits
mailing list