From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B866C433ED for ; Wed, 12 May 2021 11:27:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 78DBC613CD for ; Wed, 12 May 2021 11:27:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 78DBC613CD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgn1f-0007BG-FY for qemu-devel@archiver.kernel.org; Wed, 12 May 2021 07:27:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgmuW-0005HB-8X for qemu-devel@nongnu.org; Wed, 12 May 2021 07:20:16 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:34433) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lgmuT-0004Al-3T for qemu-devel@nongnu.org; Wed, 12 May 2021 07:20:15 -0400 Received: by mail-wr1-x429.google.com with SMTP id t18so23234488wry.1 for ; Wed, 12 May 2021 04:20:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:user-agent:from:to:cc:subject:date:in-reply-to :message-id:mime-version:content-transfer-encoding; bh=Ad+9+2MDnnVuK7GelgJgPn5SudwJaltU6W6vHSgmUQs=; b=uqo/N7xc/ULhkrQSTh1QMECLMDJG8gyP3UjVs9svOtUaa3eAp3tAjI+GZgmomcljry 4dOObT4/ZoMV6FHhrQANP4PtRgqO5XtcM9nuU04NDHeKhxrKD8vCsPws0zabvU+8QD2n 84Oe+ze7k6SMmTuCnaYSdiz1lc5yQdH8Ame94p4OOUic03sFQjO+PyZZVAi8FopjU14l LwruljCc73dgC4E1T3XIzUJy+OeePdIPTb0+uPIv3YBLITHgFxpuoaZZ8afU/5B2DqLt UmzV6Dm7t+vDhqINjVyCsnxZNLkv5nkyvkmwgi2ts1YqdCcZv4UA7FTMIFSJqf4oQvVl R/Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject:date :in-reply-to:message-id:mime-version:content-transfer-encoding; bh=Ad+9+2MDnnVuK7GelgJgPn5SudwJaltU6W6vHSgmUQs=; b=iQ9j4u54BCsCtW/2b3yza7k+74uhFH2VgtWefjMLYFwSJwFzmPdOj+3eBA9XPZn0Wh E1vfccQoZua75VFqAdnJlYX2TKwN7PZmH4s6UO3HeQeouTmFgjT5wDdWIg5XReclJWi8 +7N6ktMZbrPNAFQuSZ2PG6te7ct5w0LsXkwjANrWsqRlST7zB6jfoc0AcwHNNp+KTqOj mbvP/R1f5l2heUhrBgHXio7VgZliYPc5H0QMwV+Tac9vGXzdpGA5PPk5EzWqqZzuMXXA AIAonBU80uBJfYhk66PIPvplVSwqDqTpe6g5Pl9dI9yesR+Dt6iQb3xGP6c0cseEq3pe NyQQ== X-Gm-Message-State: AOAM5338NcZz/8BZgrkF/T74OpUeAzcq6BmY6zIZQiFPf7XMt6NoJIfc QFPB8SR73lXju/0JLw0PDsMzvA== X-Google-Smtp-Source: ABdhPJwR0VNCITjtC3B7Im2JLkOfJ1poR6GH/OLtHnCUCLENTO1Y7ulmPpZLymoL5yZunSa5DrNyuQ== X-Received: by 2002:a5d:6d8f:: with SMTP id l15mr45218594wrs.313.1620818408976; Wed, 12 May 2021 04:20:08 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id 61sm33805501wrm.52.2021.05.12.04.20.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 04:20:07 -0700 (PDT) Received: from zen (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E35581FF7E; Wed, 12 May 2021 12:20:06 +0100 (BST) References: <20210508014802.892561-1-richard.henderson@linaro.org> <20210508014802.892561-4-richard.henderson@linaro.org> <87k0o6yc74.fsf@linaro.org> <90dc8203-522a-d3d2-15b8-ad95fd654f93@linaro.org> User-agent: mu4e 1.5.13; emacs 28.0.50 From: Alex =?utf-8?Q?Benn=C3=A9e?= To: Richard Henderson Subject: Re: [PATCH 03/72] qemu/host-utils: Add wrappers for carry builtins Date: Wed, 12 May 2021 12:17:24 +0100 In-reply-to: <90dc8203-522a-d3d2-15b8-ad95fd654f93@linaro.org> Message-ID: <87sg2sfbbt.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, david@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Richard Henderson writes: > On 5/10/21 7:57 AM, Alex Benn=C3=A9e wrote: >> Richard Henderson writes: >>=20 >>> These builtins came in clang 3.8, but are not present in gcc through >>> version 11. Even in clang the optimization is not ideal except for >>> x86_64, but no worse than the hand-coding that we currently do. >> Given this statement.... > > I think you mis-read the "except for x86_64" part? > > Anyway, these are simply bugs to be filed against clang, so that > hopefully clang-12 will do a good job with the builtin. And as I > said, while the generated code is not ideal, it's no worse. > >>> +static inline uint64_t uadd64_carry(uint64_t x, uint64_t y, bool *pcar= ry) >>> +{ >>> +#if __has_builtin(__builtin_addcll) >>> + unsigned long long c =3D *pcarry; >>> + x =3D __builtin_addcll(x, y, c, &c); >> what happens when unsigned long long isn't the same as uint64_t? >> Doesn't >> C99 only specify a minimum? > > If you only look at C99, sure. But looking at the set of supported > hosts, unsigned long long is always a 64-bit type. I guess I'm worrying about a theoretical future - but we don't worry about it for other ll builtins so no biggy. > >>> + *pcarry =3D c & 1; >> Why do we need to clamp it here? Shouldn't the compiler >> automatically do >> that due to the bool? > > This produces a single AND insn, instead of CMP + SETcc. Might be worth mentioning that in the commit message.=20 Anyway: Reviewed-by: Alex Benn=C3=A9e --=20 Alex Benn=C3=A9e