[llvm] [DAG] Matched Fixedwidth Pattern for ISD::AVGCEILU (PR #85031)

Shourya Goel via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 17 13:31:02 PDT 2024


================
@@ -2529,6 +2529,23 @@ static SDValue foldAddSubBoolOfMaskedVal(SDNode *N, SelectionDAG &DAG) {
   return DAG.getNode(IsAdd ? ISD::SUB : ISD::ADD, DL, VT, C1, LowBit);
 }
 
+// Attempt to form avgceilu(A, B) from (A | B) - ((A ^ B) >> 1)
+static SDValue combineFixedwidthToAVGCEILU(SDNode *N, SelectionDAG &DAG) {
+  const TargetLowering &TLI = DAG.getTargetLoweringInfo();
+  SDValue N0 = N->getOperand(0);
+  EVT VT = N0.getValueType();
+  SDLoc DL(N);
+  if (TLI.isOperationLegal(ISD::AVGFLOORU, VT)) {
----------------
Sh0g0-1758 wrote:

> AVGFLOORU -> AVGCEILU

Updated.

> This shares quite a lot with https://github.com/llvm/llvm-project/pull/84903 and could be combined into the same function once that is submitted

Sure. 

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


More information about the llvm-commits mailing list