From nobody Mon Aug 01 05:45:40 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Lx6Y03GrWz4XVN6; Mon, 1 Aug 2022 05:45:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Lx6Y02dw3z3DBT; Mon, 1 Aug 2022 05:45:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659332740; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yC+ErjEyTsXx6wtCxSFHvxxdoPREfdLfhh73gnzt6Bk=; b=duPK87mADV6kSet7+4XaXu7ASTZ4ESz6E8KNSDptmmzUyD3rOfao1r6b/5WN9/KERa/dJI KhlscrUQEoJrdbhU5tid/wi1dJfHj9zwIFd9YlqhHbMYpM7hoiRt+o+jz8JdLqRldH9kti d8n5FU/y+s2AV+3Dj3ga1/HLZ8zCjlQjttuFdht7gc4ASd79T6DgTWOZlmL9hgiaC3HuL0 p3js+jB6N4iOQRLAFlV6+rKmI7M9o4wRcMa3DNj4l8dw6NIryPZizjg2fb85h+GDcj1S9o Ysi5oNaizn4UdziBu2M+xMwUqdkiyuOSnIt85m+9CxSl1nhTpexlyetq3ROWTw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Lx6Y01Sg3zN74; Mon, 1 Aug 2022 05:45:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2715jeeb034717; Mon, 1 Aug 2022 05:45:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2715jeeh034716; Mon, 1 Aug 2022 05:45:40 GMT (envelope-from git) Date: Mon, 1 Aug 2022 05:45:40 GMT Message-Id: <202208010545.2715jeeh034716@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Doug Moore Subject: git: 6f7a96cfe537 - stable/13 - rb_tree: optimize tree rotation List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dougm X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6f7a96cfe53716cc65e6f2ac8eea4d8aeafd1e56 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659332740; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yC+ErjEyTsXx6wtCxSFHvxxdoPREfdLfhh73gnzt6Bk=; b=NeZZ8I10SGNS9zBGfyA00GTtoVC0eZT0rvWgmV69nCWaFGBWSfTxPIL4Sxgk7ZtMkgI1xT MW8Vx9yMQebLUI9Su6qPiOlDSCeBlJZuNKujPNsZFToQepUoojoErSrBMT/iXLlEaUzx0M wPxVyQuTLwnDO91lMQB5UNzPcQWXEuw3UwydzNfialfM89cXuDAb/FhWRPQezSuWdK1bby j6I8eH8reaOpaxGe8OvyZrzdU0aZHUeivymFWLbtIVRQYYv/6zcuxJ1Mll7FqB0pXQOk0w jrXfaFPHqknWjHTACcZOrZ9kSq+RkEIFUGUCMHn5Y2wOPnYz89xGOp0Qlt3DGg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1659332740; a=rsa-sha256; cv=none; b=BUul6pGJsoJqEx8rQhLWyIbDUDdMPBOTOCuh0gmiBIKe0MVaoFbSKkjmZJ5Su3iGWnH/JC sgJ/3ZHCTF7bckOopoEYA53ovtgO7mvjy5ZZQeW+yZmqYoUhBJ48z2+MC5FmQ5UdQ6NtMC 69oiVvt3AD364GnqRGlzfXt04ePQKnM2surcnyg+bUWk/teXhfdoEjaHE6rQslrrw8rdI6 E9S1bRzAafrqHV2JSvxBBNhNEO1RyCRwHKQPUZQtUjHi/RGEyubeCsi6TwPjtjgGB/ldMi HQ6gI7Y2+/kXDFDow55kEBXLCF9EWPBLktyvKa4EsnlxL2J4X6gAfYNZ4p7Tbg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=6f7a96cfe53716cc65e6f2ac8eea4d8aeafd1e56 commit 6f7a96cfe53716cc65e6f2ac8eea4d8aeafd1e56 Author: Doug Moore AuthorDate: 2022-06-25 07:40:16 +0000 Commit: Doug Moore CommitDate: 2022-08-01 05:43:08 +0000 rb_tree: optimize tree rotation The RB_ROTATE macros begin with fetching a field via a pointer. In most cases, that value is one that has already been pulled into a register, and the compiler cannot infer that. So, to eliminate those needless fetches, have the caller of the RB_ROTATE macros present the data in the third macro parameter, rather than having the macro fetch it. Differential Revision: https://reviews.freebsd.org/D35520 (cherry picked from commit 61c74fb66f1bef776923cbd5b2a62fb06b003f0c) --- sys/sys/tree.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/sys/tree.h b/sys/sys/tree.h index 2206469db492..f6252ff7ac25 100644 --- a/sys/sys/tree.h +++ b/sys/sys/tree.h @@ -380,7 +380,6 @@ struct { \ } while (/*CONSTCOND*/ 0) #define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ - (tmp) = RB_RIGHT(elm, field); \ if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \ RB_SET_PARENT(RB_RIGHT(elm, field), elm, field); \ } \ @@ -392,7 +391,6 @@ struct { \ } while (/*CONSTCOND*/ 0) #define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \ - (tmp) = RB_LEFT(elm, field); \ if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \ RB_SET_PARENT(RB_LEFT(elm, field), elm, field); \ } \ @@ -484,6 +482,7 @@ name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ } \ RB_FLIP_RIGHT(parent, field); \ if (RB_RED_RIGHT(parent, field)) { \ + child = elm; \ elm = parent; \ continue; \ } \ @@ -505,6 +504,7 @@ name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ } \ RB_FLIP_LEFT(parent, field); \ if (RB_RED_LEFT(parent, field)) { \ + child = elm; \ elm = parent; \ continue; \ } \ @@ -561,6 +561,7 @@ name##_RB_REMOVE_COLOR(struct name *head, \ RB_FLIP_LEFT(parent, field); \ else if (!RB_RED_RIGHT(sib, field)) { \ RB_FLIP_LEFT(parent, field); \ + elm = RB_LEFT(sib, field); \ RB_ROTATE_RIGHT(head, sib, elm, field); \ if (RB_RED_RIGHT(elm, field)) \ RB_FLIP_LEFT(sib, field); \ @@ -591,6 +592,7 @@ name##_RB_REMOVE_COLOR(struct name *head, \ RB_FLIP_RIGHT(parent, field); \ else if (!RB_RED_LEFT(sib, field)) { \ RB_FLIP_RIGHT(parent, field); \ + elm = RB_RIGHT(sib, field); \ RB_ROTATE_LEFT(head, sib, elm, field); \ if (RB_RED_LEFT(elm, field)) \ RB_FLIP_RIGHT(sib, field); \