From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id 2A1163858C1F for ; Wed, 7 Jun 2023 23:05:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2A1163858C1F 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-x629.google.com with SMTP id d9443c01a7336-1b04949e5baso69737505ad.0 for ; Wed, 07 Jun 2023 16:05:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686179130; x=1688771130; 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=bq8HLGWmLwbs32Jezl358qpdk0wOQTLAkdkQSCCBe4Q=; b=fNNtjPSlP/CgymTYJicAE5YNxX9C2k4npqMy6gzpS8flxoVnQNN1fM9pQ0WzdpTzej CNshwr9v5uYxen9ib12FH+NsGODWJzDJ1s0ABxuhReVAkL4BFXMJvsEcBsv2j5wBNLI0 YwdskXAkNCBERTliwLct3xU+V5OSP0ow5oYt776GxkQz/SSKRFSzcFhVtQbMjuxfCjsZ ua+TfHoGq0WjvVqk2/t++zrLWY0x1IEiaTKfHGItTZWJ4/L/epY7SXixeH8f0vzrytkK 4CK1tkCGBHE/dR+cAkkK/dZD+hI6c2tx1uDQLyie1ymHM7vj3/12QJb6csuSA2VS/biq YBSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686179130; x=1688771130; 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=bq8HLGWmLwbs32Jezl358qpdk0wOQTLAkdkQSCCBe4Q=; b=LgjcvOGe/UWVd9cTU7Qds37sfDk6TQEgvcWWClksT88gsGZVLwBP/PWBUZrzXO7j43 N0RwR9LuSDnUfUF+C6K9EQrh3r4mrUd5R0YNda4i75kQDhbawRCnzhC4nPI8qDnAC6Ae iyJepVDhY0hRssjwOLboGy6M7QNyEbbkcydEcUei36VSUOAwKjqLtz+m58RediqQN80P evbc1DOQKuVoChoBuqZ8hWnSVYgaGD5n2l7DJbT+ozkQwV5R0xjDBKc/h9KRU+g2i8Ud MMqveqtJ+lCgSdE+ORJWaMKSmRJ0VHQ/pNj09wM+AMC2YhSmIdPmdO6/DDXFODzrzPIq 6oiA== X-Gm-Message-State: AC+VfDw7qgO7VEiNjbT1+Ck4PdJXx4W2N/WlOF0a55jHzwhsA+IRrXZC 6cINmpiAz5Ugoq9cb0zeX9T04cJJbFXFemB7LVU= X-Google-Smtp-Source: ACHHUZ7tjDr/xyqQk4BP7qZMO1CwINJWTUUSMdpbO6rqwkMxrAZjZ9mWre5lAF0lD2rdZiVMhwsb8AuJhkSpuApUWvk= X-Received: by 2002:a17:903:110c:b0:1b0:2d08:eb51 with SMTP id n12-20020a170903110c00b001b02d08eb51mr7155106plh.12.1686179130095; Wed, 07 Jun 2023 16:05:30 -0700 (PDT) MIME-Version: 1.0 References: <20230607213217.3052696-1-apinski@marvell.com> <20230607213217.3052696-2-apinski@marvell.com> In-Reply-To: From: Andrew Pinski Date: Wed, 7 Jun 2023 16:05:17 -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=-2.0 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 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 th= e 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, Andrew > > jeff >