From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by sourceware.org (Postfix) with ESMTPS id 522753858D32 for ; Tue, 13 Jun 2023 08:32:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 522753858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qk1-x72e.google.com with SMTP id af79cd13be357-75efda265f8so64248385a.0 for ; Tue, 13 Jun 2023 01:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686645134; x=1689237134; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=I8GkV2rl6q2Tu2bbu8yehxm+UUy5bAAK7hAdpyRO76Y=; b=kUrQIcjE1FPQuSCiSFwlDaYoMQnZRgeKT0ado0JF6/1HWAoIJupgNG/qTFvsVGZYE1 6HocMHSGQcdrGboi96KqGaWJrj23rICC1nJLW5cJtZhT/8GXHZy8HWvy0etGECMUykef 9mRmqtQ43iAxFIF7aivHTiboWP8P3tbxSp7U0/r0oQutk1SUNHVs1m27xY5l49EVWzdW fa2Ip13rNjeI4sn7hfh4BBa2Zo9JDx1FETgk/e0MpNPgSgnR0EEsc+s4naAd2uiSdxjQ EM7DrVcFhNakx7qWIW2wZ/QInsveq6wBtGKNY61ExCLMQV0U5HhDvFsDBkrg/3pGI/A7 5k1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686645134; x=1689237134; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I8GkV2rl6q2Tu2bbu8yehxm+UUy5bAAK7hAdpyRO76Y=; b=UdtLhygcOn6U1WCU+vpffQ//FmUrWNoCNMlpej4ztrs1BB/ZNZyjMVLbRi8dk9uVhD 6+blv+YQPmUHFtCMbhFrl1SrkrreaHaM4n3aZxtKDhDUVAa1g6h2pfJTF3cbvpltB/5F E1kbtFRZNfdMSA5bb4IM+xifdXOqf+AywDMsv3t8Fpahj4PTkIlGtF0g+keRhp7oXJvD cMoX8aauPH2dYljwHkpEyijrG8p+YZh9tvXq4qsEI3qFwXDoTXsvsFe0xmyDFSyxahHL dLJsJo76l/Ug0H+Ne9PJr9+FE2bx+oAIpaOuI/XbOa5qec5LTMQXmWpevOjJnSldbKV8 957A== X-Gm-Message-State: AC+VfDyswyfbwAVsfBKEsWYlikQljSlLDUHR7JT2FrWnhFEJp3/lXPle r8o5edySK0FnX7/vw4V6d4IFdg+xEGTPB1c4PsY= X-Google-Smtp-Source: ACHHUZ56faRCF5mp8YQLmBbhAfSC2EiSxIKKU43HpdIcOZNMKCdtEUZSIyoirUGJXw/ptyOSblYxoqL2NluYfwhHaFo= X-Received: by 2002:a37:68ca:0:b0:75d:5209:c2ed with SMTP id d193-20020a3768ca000000b0075d5209c2edmr9853507qkc.27.1686645134211; Tue, 13 Jun 2023 01:32:14 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Uros Bizjak Date: Tue, 13 Jun 2023 10:32:03 +0200 Message-ID: Subject: Re: Patch ping (Re: [PATCH] middle-end, i386: Pattern recognize add/subtract with carry [PR79173]) To: Jakub Jelinek Cc: Richard Biener , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, Jun 13, 2023 at 9:06=E2=80=AFAM Jakub Jelinek wr= ote: > > Hi! > > On Tue, Jun 06, 2023 at 11:42:07PM +0200, Jakub Jelinek via Gcc-patches w= rote: > > The following patch introduces {add,sub}c5_optab and pattern recognizes > > various forms of add with carry and subtract with carry/borrow, see > > pr79173-{1,2,3,4,5,6}.c tests on what is matched. > > Primarily forms with 2 __builtin_add_overflow or __builtin_sub_overflow > > calls per limb (with just one for the least significant one), for > > add with carry even when it is hand written in C (for subtraction > > reassoc seems to change it too much so that the pattern recognition > > doesn't work). __builtin_{add,sub}_overflow are standardized in C23 > > under ckd_{add,sub} names, so it isn't any longer a GNU only extension. > > > > Note, clang has for these has (IMHO badly designed) > > __builtin_{add,sub}c{b,s,,l,ll} builtins which don't add/subtract just > > a single bit of carry, but basically add 3 unsigned values or > > subtract 2 unsigned values from one, and result in carry out of 0, 1, o= r 2 > > because of that. If we wanted to introduce those for clang compatibili= ty, > > we could and lower them early to just two __builtin_{add,sub}_overflow > > calls and let the pattern matching in this patch recognize it later. > > > > I've added expanders for this on ix86 and in addition to that > > added various peephole2s to make sure we get nice (and small) code > > for the common cases. I think there are other PRs which request that > > e.g. for the _{addcarry,subborrow}_u{32,64} intrinsics, which the patch > > also improves. > > I'd like to ping this patch. I briefly went over the x86 part (LGTM), but please get a middle-end approval first. Thanks, Uros. > > Thanks. > > Jakub >