From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id DDFA73858D33; Wed, 9 Nov 2022 08:00:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DDFA73858D33 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-ed1-x533.google.com with SMTP id f7so25977875edc.6; Wed, 09 Nov 2022 00:00:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Ca5c4sRjy9Z1SepGalPkTt/IUlmwwFjJBBsL5fgSPSk=; b=fJFguuKdwFxZwgBs6Z1fAmfNOgbJYPJSBcETqouJiToBYLwusM7iZXV72MPtKqJpZS txr8k9/+UZHXFSYOIYn7bcIfCe5OfLIBF0xrXTLyzjm7IpGw+7rIfE4f9rUuezgId7wO 7V+NNGKjb+eSiX3aQhd6DphDyE1Gcbz+t80Ch034vs/WwBxL7GPZA9RSlQmS6WWUOp2S QqliD4R4fHbYxMJioE01+wg5MTd4/DwRso8b/GzzQNVUajGnWawfZisvNQwrpp9O7QY1 RGglHrgKresNyjkhzZv4gEL42ZRY+2ilNyC/sVl4FxdCM0Ph1OqEYE1hjPvXgVBMlGXY XIcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=Ca5c4sRjy9Z1SepGalPkTt/IUlmwwFjJBBsL5fgSPSk=; b=uSgea445iOkP7ct7GVcQaMgyX78QWdCKYh7j7KYpbUuVojNr/0Tc2c3L1hNU7VFGFL Qk1Y+IXcw0hNvFofv/0ox00mtfCzcD1UAsopBd53q2wS2irGW8OP8+p7yz5r+xyddRf5 qDx+ihS/YtyO7iDmAuBhNTebqTF7CWoNxm97nGw36i3heIfDpdyRV9F33hVEfRwntmtP Nx8l2bKNFKbXk4QXYuvGqTpbpulx/zh85bfoZewcGwKPkBQd5DK9yunezYB/7iLLSXc+ lYImXT7cik1WSOW5xHJ4HxpWQfL2HR+fRopBPdlIJnACALgNLh4TrzNj0jYX9YHOrckz +GuQ== X-Gm-Message-State: ACrzQf3b2h5GX5MSEqyX7XW4cpsno1cp6BVe9pgPk37aFLCLPUsQuxpI jrVgOkLuX8B2crCHZk/NQb11jpBu9178uKG96wg= X-Google-Smtp-Source: AMsMyM6UF1+nYBGp8xP7+n7eahaIYCydXdFtCbmaHA/gLkCGYgNhMDt9DW8R/AH9AeazEucyvy2c77WSnSrAMDTXl/w= X-Received: by 2002:a05:6402:3457:b0:463:2017:ae64 with SMTP id l23-20020a056402345700b004632017ae64mr55468149edc.218.1667980846590; Wed, 09 Nov 2022 00:00:46 -0800 (PST) MIME-Version: 1.0 References: <20220905214437.1275139-1-philipp.tomsich@vrull.eu> <23b39c10b30043318e05a5c44cc76591@huawei.com> <7b6d19fcef784a019c89e77c9917c5a8@huawei.com> In-Reply-To: From: Richard Biener Date: Wed, 9 Nov 2022 09:00:34 +0100 Message-ID: Subject: Re: Re: [PATCH] [PHIOPT] Add A ? B + CST : B match and simplify optimizations To: =?UTF-8?B?6ZKf5LqR5b63?= Cc: Zhongyunde , Andrew Pinski , "Weiwei (weiwei, Compiler)" , "hongtao.liu@intel.com" , "gcc-patches@gcc.gnu.org" , "Zhangwen(Esan)" Content-Type: multipart/alternative; boundary="000000000000da6f6505ed050d55" X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP 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: --000000000000da6f6505ed050d55 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Nov 8, 2022 at 4:51 PM =E9=92=9F=E4=BA=91=E5=BE=B7 wrote: > At 2022-11-08 22:58:34, "Richard Biener" > wrote: > > >On Sat, Nov 5, 2022 at 10:03 AM Zhongyunde via Gcc-patches > > wrote: > >> > >> > >> > -----Original Message----- > >> > From: Andrew Pinski [mailto:pinskia@gcc.gnu.org] > >> > Sent: Saturday, November 5, 2022 2:34 PM > >> > To: Zhongyunde > >> > Cc: hongtao.liu@intel.com; gcc-patches@gcc.gnu.org; Zhangwen(Esan) > >> > ; Weiwei (weiwei, Compiler) > >> > ; zhong_1985624@163.com > >> > Subject: Re: [PATCH] [PHIOPT] Add A ? B + CST : B match and simplify > >> > optimizations > >> > > >> > On Fri, Nov 4, 2022 at 11:17 PM Zhongyunde > >> > wrote: > >> > > > >> > > hi, > >> > > This patch is try to fix the issue > >> > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107190, > >> > > would you like to give me some suggestion, thanks. > >> > > >> > This seems like a "simplified" version of > >> > https://gcc.gnu.org/pipermail/gcc-patches/2021-November/584411.html > >> > which just handles power of 2 constants where we know the cond will = be > >> > removed. > >> > We could do even more "simplified" of 1 if needed really. > >> > What is the IR before PHI-OPT? Is it just + 1? > >> > >> Thanks for your attention. It is + 4294967296 before PHI-OPT (See det= ail https://gcc.godbolt.org/z/6zEc6ja1z) > >> So we should keep matching the power of 2 constants ? > >> > >> > Also your pattern can be simplified to use integer_pow2p in the matc= h part > >> > instead of INTEGER_CST. > >> > > >> Apply your comment, thanks > > > >How does the patch fix the mentioned bug? match.pd patterns should make= things > >"simpler" but x + (a << C') isn't simpler than a ? x + C : x. It > >looks you are targeting > >PHI-OPT here, so maybe instead extend value_replacement to handle this c= ase, > >it does look similar to the case with neutral/absorbing element there? > > > >Richard. > > Thanks. This patch try to fix the 1st issued mentioned in 107090 =E2=80= =93 [aarch64] sequence logic should be combined with mul and umulh (gnu.org= ) > Sure, I'll take a look at the function value_replacement. > I have also noticed that the function of two_value_replacement is very cl= ose to patch I want to achieve, and it may be easy to extend. > It seems can be expressed equally in match.pd (called by match_simplify_r= eplacement), so how do we > choose where to implement may be better? > > I think that if we realize that we don't want a simplification to always apply (like by checking for canonicalize_math_p ()), then we should look for a pass which is a good fit and since you add the pattern to trigger a PHI-OPT optimization that looked like an obvious choice ... ``` > > /* Do the replacement of conditional if it can be done. */ = if (!early_p = = && !diamond_p = = && two_value_replacement (bb, bb1, e2, phi, arg0, arg1)) = cfgchanged =3D true; = = else if (!diamond_p = && matc= h_simplify_replacement (bb, bb1, e1, e2, phi, = arg0, = arg1, early_p)) = cfgchanged =3D true; > > ``` > >> > Thanks, >> > Andrew >> >> > > --000000000000da6f6505ed050d55--