[llvm] [DAG] Matched FixedWidth pattern for ISD::AVGFLOORU (PR #84903)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 17 04:33:39 PDT 2024
================
@@ -2820,6 +2820,22 @@ SDValue DAGCombiner::visitADDLike(SDNode *N) {
return SDValue();
}
+// Attempt to form avgflooru(A, B) from add(and(A, B), lshr(xor(A, B), 1))
+static SDValue combineFixedwidthToAVGFLOORU(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)) {
+ SDValue A, B;
+ if (sd_match(N, m_Add(m_And(m_Value(A), m_Value(B)),
+ m_Srl(m_Xor(m_Deferred(A), m_Deferred(B)),
+ m_SpecificInt(1))))) {
+ return DAG.getNode(ISD::AVGFLOORU, DL, VT, A, B);
+ }
+ }
+}
----------------
jayfoad wrote:
Missing `return SDValue()` at the end of the function. (Doesn't your compiler warn about that?)
https://github.com/llvm/llvm-project/pull/84903
More information about the llvm-commits
mailing list