From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id C9B553858C54 for ; Wed, 7 Jun 2023 23:19:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C9B553858C54 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-pl1-x62b.google.com with SMTP id d9443c01a7336-1b04706c85fso73796865ad.0 for ; Wed, 07 Jun 2023 16:19:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686179979; x=1688771979; 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=XIc5SqQGtu0VO8TheQWolNEr7I3WZi+h/QVPu5n0XWg=; b=DhxG8csuOlMY4FstPdBT8AiGmBsJR0pg/uA34uacvo7Nbpoq1Tdr3HCOa6f5ApMoSK 3GEMiljG2/N4zX/2e9tGutz1HPxUCNbqmFhPJrAy0pYx8WXkki8rOHU29vPrLC++hapl 2MydjPsQ8nK5Md/QdxoXCHB1smbksUm72mADR6vaOJSrsuRorfTteK8p/HJFMUhlnbp7 Mql99oRvftBzXmkt4TI0RtKWsH+w4FBSmVOdpUuWO2wgWknZ7vnxEkC/IHqC6ZI/R4Bh cRF84k8jOWxM8Q+oLjJtvo59+eOGfmAn7SH/pAflFdfbH3XhfuC3cKhouEKTBT88l/P7 Y0Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686179979; x=1688771979; 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=XIc5SqQGtu0VO8TheQWolNEr7I3WZi+h/QVPu5n0XWg=; b=QQHQjfAbQ7zCXwJsihYmk2u9JNjUHP7NVpX4GvoadkTrzqMbqbBg1AMqsgyX4nOUS3 93OyhVJoHP/DzcAe15FJ06Qc5ACCYW4FpqhbklRpKb1X+ADf/OwJ5AVhiDP9IoFjSYtz lpCCe5EccvKmfqID2cUIIZHnQ8B/8IA6yFngaIHWEdmhWiNCPv5OF2Kl6c3mVoFBXd7F owllvsxPts2RrStmcRZRFGUsbtbfIPXh6Zro2DDCRa/6vbDvuBvrERDYKQjRqKY06Exz q8JyxHUSt0EHwgfbOfuHVzslVQtdkpYOyM7qiwP2UxvDRw4NLKL7GtqY2q5B4/nSi7fw 3sUw== X-Gm-Message-State: AC+VfDzFXqPHoKhTNf5v7xDjeFimx5he0Nbgr2l+34v0J3E7kZ512vJK vDfnB9mHb4DqgTFezngKTzHKnpL+I8JZytOeAAU= X-Google-Smtp-Source: ACHHUZ7R3DgzOquZrc6H+it7l0znc/7HDDcDFZd0Meaw+OrYCUaU7/AxVqFZm8Vm+SLVo+XbEbtCAp+lwPJKxc7IRho= X-Received: by 2002:a17:903:11c6:b0:1b0:1608:d7eb with SMTP id q6-20020a17090311c600b001b01608d7ebmr7813608plh.5.1686179978705; Wed, 07 Jun 2023 16:19:38 -0700 (PDT) MIME-Version: 1.0 References: <20230607213217.3052696-1-apinski@marvell.com> <20230607213217.3052696-2-apinski@marvell.com> <3bfa36d2-7fff-164a-c74b-8c82300b8a68@gmail.com> In-Reply-To: <3bfa36d2-7fff-164a-c74b-8c82300b8a68@gmail.com> From: Andrew Pinski Date: Wed, 7 Jun 2023 16:19:25 -0700 Message-ID: Subject: Re: [PATCH 2/3] Change the `zero_one ==/!= 0) ? y : z y` patterns to use multiply rather than `(-zero_one) & z` To: Jeff Law Cc: Andrew Pinski , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,PLING_QUERY,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 Wed, Jun 7, 2023 at 4:11=E2=80=AFPM Jeff Law wro= te: > > > > On 6/7/23 17:05, Andrew Pinski wrote: > > On Wed, Jun 7, 2023 at 3:57=E2=80=AFPM Jeff Law via Gcc-patches > > wrote: > >> > >> > >> > >> On 6/7/23 15:32, Andrew Pinski via Gcc-patches wrote: > >>> Since there is a pattern to convert `(-zero_one) & z` into `zero_one = * z` already, > >>> it is better if we don't do a secondary transformation. This reduces = the extra > >>> statements produced by match-and-simplify on the gimple level too. > >>> > >>> gcc/ChangeLog: > >>> > >>> * match.pd (`zero_one =3D=3D/!=3D 0) ? y : z y`): Use > >>> multiply rather than negation/bit_and. > >> Don't you need to check the types in a manner similar to what the A & = -Y > >> -> X * Y pattern does before you make this transformation? > > > > No, because the convert is in a different order than in that > > transformation; a very subtle difference which makes it work. > > > > In A & -Y it was matching: > > (bit_and (convert? (negate > > But here we have: > > (bit_and (negate (convert > > Notice the convert is in a different location, in the `A & -Y` case, > > the convert needs to be a sign extending (or a truncation) of the > > negative value. Here we are converting the one_zero_value to the new > > type so we get zero_one in the new type and then doing the negation > > getting us 0 or -1 value. > THanks for the clarification. OK for the trunk. So even though my transformation is correct based on what was done in match.pd but that was broken already for signed one bit integers: ``` struct s { int t : 1; }; int f(struct s t, int a, int b) { int bd =3D t.t; if (bd) a|=3Db; return a; } ``` I am going to withdraw this patch and fix that up first. Thanks, Andrew > > jeff