From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alex Gramiak Newsgroups: gmane.emacs.devel Subject: Using __builtin_expect (likely/unlikely macros) Date: Sun, 14 Apr 2019 18:15:44 -0600 Message-ID: <87a7gst973.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="267207"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 15 02:16:26 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hFpIQ-0017L8-Jg for ged-emacs-devel@m.gmane.org; Mon, 15 Apr 2019 02:16:26 +0200 Original-Received: from localhost ([127.0.0.1]:42461 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hFpIP-000440-KC for ged-emacs-devel@m.gmane.org; Sun, 14 Apr 2019 20:16:25 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:50774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hFpHn-0003ym-6Z for emacs-devel@gnu.org; Sun, 14 Apr 2019 20:15:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hFpHm-0001vS-Dq for emacs-devel@gnu.org; Sun, 14 Apr 2019 20:15:47 -0400 Original-Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:36771) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hFpHm-0001v0-63 for emacs-devel@gnu.org; Sun, 14 Apr 2019 20:15:46 -0400 Original-Received: by mail-pl1-x632.google.com with SMTP id ck15so7681288plb.3 for ; Sun, 14 Apr 2019 17:15:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:user-agent:mime-version; bh=Poca38E8hhJhfo1Bjjc7vDv0Q118ohSA4PZBhzF/hco=; b=Xj2rtaezakH+K5txrKlHqYPI5f6cobg2ER5OvkvExID4Rg4UZGkUNraD1evYwsC9Gn i07v6rZjSEwhic3EyEsQzHUj4R5kMoI2MzTBMMnx/46JLzIY9HO/SmWG9tSAMpbefwq3 YgUiI57Gw0k41H1CCYoPdDUhHnhEk9RlrdT8ZDbBJ1qOXFmsDgRm1sdPiEC66aIBz4bl XlEGxOGSBbRrEH7BCthUOCY0XPyhwpj+13DC9ZpDxtMeYObjFcTWgc6mjfG7gUKGoZv3 9SFJYvQKGdlP1zlgZV90SiUSQkHSvvxUdUqUoFesZ/YjSqf5QHZDllwjj35KrTpC1SEw orcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version; bh=Poca38E8hhJhfo1Bjjc7vDv0Q118ohSA4PZBhzF/hco=; b=t+B/ctVckbD96aTeCa4odCJmPKxTXEShNfDDcvW4CW5C3KfJpIuDPpBbnCRoOG/FyZ 6NTg6Qbk7GH0xsDzZnmAo6GFTpHCXjpxZ5hq7zvlbBKE6m+8AiMxIElLOSTzShLnXDhT +bugTyDM+RFd0ooOXCM3fdLOBh/iy3Sm7F7PJgtWDfi4GJ17Xza/wXIO/NNV5UXZrCWG 1O4gHaSin8f6Rv5BaKzYAWBnpBtDG2PEBFZUdOe9HWZK4lIh3lxo2o6t0aY7zjmdae0v 45oKJ3br2TjPRsNjvslAmlV3JY26bcNUHQPqlQAkI1kA/OGY77QS4Qawz4JeEje4mQp+ DWGQ== X-Gm-Message-State: APjAAAW+MXqn9Hxd98TgVfKIiXM75HlZPrfCZFogp6TDoRbCyhXwjnde GB+yyye8utm04PtPw6zU8VyrxVI4 X-Google-Smtp-Source: APXvYqxsqwHOc8hHj1wkoW8WhR8TZmnv1UADrb5vikIguSLojLOz5lhdue9TOcIHk3zH7XA1PWEOLA== X-Received: by 2002:a17:902:3283:: with SMTP id z3mr15129658plb.281.1555287344836; Sun, 14 Apr 2019 17:15:44 -0700 (PDT) Original-Received: from lylat ([2604:3d09:e37f:1500:1a72:4878:e793:7302]) by smtp.gmail.com with ESMTPSA id u63sm36800446pgd.16.2019.04.14.17.15.43 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 14 Apr 2019 17:15:44 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::632 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:235466 Archived-At: Would using these, if available, be acceptable? I noticed that some code in configure.ac already defines HAVE___BUILTIN_EXPECT, though I couldn't see what part of autoconf does this. Good candidates here include the conditionals around emacs_abort/fatal, and possibly in cases like the *alloc procedures and xfree. Even if there's no noticeable speedup, I think that the likely/unlikely macros are a nice way to indicate that a branch is exceedingly rare/common. #define unlikely(expr) __builtin_expect(!!(expr), 0) #define likely(expr) __builtin_expect(!!(expr), 1)