From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by sourceware.org (Postfix) with ESMTPS id 0924E3858D35 for ; Fri, 16 Jun 2023 23:14:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0924E3858D35 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-oi1-x230.google.com with SMTP id 5614622812f47-39e86b3da59so985165b6e.3 for ; Fri, 16 Jun 2023 16:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686957276; x=1689549276; 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=F1feJCb3sYWlMqoZ3NSU3wyW2CkGP+z+Qq4cfILG9xg=; b=B8Mry1rlQkz27lK4VqLX3uaJ332JL63wjiOxAZ5UaarRyEJYxzYXnkw3peWd8a8yAo G35eHR61ZcVd+B+2vvWHoL16vv+TCFEuyXXxasqKfEAyd0nnkLXO0SbZiebUTE0qI7Iy VpyCXsnBCUNZLEuvTO7D+pYPOSwi2HjT3dbRpk5EALsUXaQH+vl5zbJW6HyLKkjpZbH4 sqR7lyG9f9vXCd5qcTEUmCcVOI5IaNMbLq9+GOwvld2iXbkgQGNDeBUq6DCKKIkboiQf HG97WHRofc91aYqW8yhgSoBZzQh5sgVvXBWdBxNNK+4HXDFzO8B9Y8oHzUss5k9GcanJ HpsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686957276; x=1689549276; 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=F1feJCb3sYWlMqoZ3NSU3wyW2CkGP+z+Qq4cfILG9xg=; b=NTWNHQ1sfLur7u3qSHvDr9rEtcC9yBhbpXS38GcK21qyL2IGqI7Hw7CHgGdGmh5Vi5 pedORPGYMi7QZ49OBR3NYPydzHN4UBRWKUP1hFUMJDf4VK2U55wjtV2fCKLt0Ep1MRZ3 01Md7ZGQY9Y/FcC7jErRLTcJfle1fPViyqpmO0Lb/i8MTPY1IdHgiLBRH9eHvkvz06Gd 6TBw72fgy+HimrxB92O6iiqvC5GJiC27p0M9BK/Y6JcQf1EWj7uW5/XF5s8UByhmzVhU yhGe3fMwkgpf06urygkOzACpmGR1t++SaJHGb2zJ7wIUhG92oh9McFcHUZbAXhXXmFGb GJOw== X-Gm-Message-State: AC+VfDz6VIqrcTn0ch7GaolPaAuMDLXNfoq9gWBFFAr4A+pGv/Zficma KciEn04041qLlg+SBjYXP4CwmMQOqoeAyJdYBb4= X-Google-Smtp-Source: ACHHUZ5CzMTzn/pTH9atpZk/7yaZVsyLSq/x4vxw3wgPnNH3fq1OuBHrZc/OZSyT2mWvUyAecp9H6pqfDwYUhJhrwQc= X-Received: by 2002:a54:4888:0:b0:398:937:6018 with SMTP id r8-20020a544888000000b0039809376018mr3336098oic.10.1686957275848; Fri, 16 Jun 2023 16:14:35 -0700 (PDT) MIME-Version: 1.0 References: <20230616114549.47732138E8@imap2.suse-dmz.suse.de> In-Reply-To: <20230616114549.47732138E8@imap2.suse-dmz.suse.de> From: Andrew Pinski Date: Fri, 16 Jun 2023 16:14:23 -0700 Message-ID: Subject: Re: [PATCH] tree-optimization/110278 - uns < (typeof uns)(uns != 0) is always false To: Richard Biener Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,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 Fri, Jun 16, 2023 at 4:46=E2=80=AFAM Richard Biener via Gcc-patches wrote: > > The following adds two patterns simplifying comparisons, > uns < (typeof uns)(uns !=3D 0) is always false and x !=3D (typeof x)(x = =3D=3D 0) > is always true. A few more that should be done (I will file a bug in a few minutes): `x =3D=3D (typeof x)(x =3D=3D 0)` is always false. `x =3D=3D (typeof x)(x !=3D 0)` is `(unsigned_type)x <=3D 1` `x !=3D (typeof x)(x !=3D 0)` is `(unsigned_type)x > 1` `uns <=3D (typeof uns)(uns !=3D 0)` -> `uns <=3D 1` `uns > (typeof uns)(uns !=3D 0)` is `uns > 1` `uns >=3D (typeof uns)(uns !=3D 0)` is always true That should be all of them I think and I think I did it correctly. > > Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. > > PR tree-optimization/110278 > * match.pd (uns < (typeof uns)(uns !=3D 0) -> false): New. > (x !=3D (typeof x)(x =3D=3D 0) -> true): Likewise. > --- > gcc/match.pd | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/gcc/match.pd b/gcc/match.pd > index 264f9cb8a40..48b76e6a051 100644 > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -6410,6 +6410,17 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > (if (cmp =3D=3D GT_EXPR) > (lt (view_convert:st @0) { build_zero_cst (st); }))))))))))) > > +/* unsigned < (typeof unsigned)(unsigned !=3D 0) is always false. */ > +(simplify > + (lt:c @0 (convert (ne @0 integer_zerop))) > + (if (TYPE_UNSIGNED (TREE_TYPE (@0))) > + { constant_boolean_node (false, type); })) > + > +/* x !=3D (typeof x)(x =3D=3D 0) is always true. */ > +(simplify > + (ne:c @0 (convert (eq @0 integer_zerop))) > + { constant_boolean_node (true, type); }) > + > (for cmp (unordered ordered unlt unle ungt unge uneq ltgt) > /* If the second operand is NaN, the result is constant. */ > (simplify > -- > 2.35.3