[llvm] [llvm] Add KnownBits implementations for avgFloor and avgCeil (PR #86445)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 5 01:58:32 PDT 2024


================
@@ -3419,18 +3419,39 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
       Known = KnownBits::mulhs(Known, Known2);
     break;
   }
-  case ISD::AVGFLOORU:
-  case ISD::AVGCEILU:
-  case ISD::AVGFLOORS:
+  case ISD::AVGFLOORU: {
+    Known = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
+    Known2 = computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1);
+    Known = Known.zext(BitWidth + 1);
+    Known2 = Known2.zext(BitWidth + 1);
+    Known = KnownBits::avgFloorU(Known, Known2);
+    Known = Known.extractBits(BitWidth, 1);
----------------
jayfoad wrote:

The zext/extract is stuff is unnecessary and wrong.
```suggestion
    Known = KnownBits::avgFloorU(Known, Known2);
```

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


More information about the llvm-commits mailing list