From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id 9BF00385F012 for ; Wed, 29 May 2024 11:52:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9BF00385F012 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9BF00385F012 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::134 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716983553; cv=none; b=ab1dewyamdjtP3QgskMGeDSNpsJGvoG5M0NyEXXecV/PkZUkIvDIi/7vWUnZHvaMq2G6Yi+Voki5A1JFT+gvFqnHzS7a+bui0A7kMeLomx4k/xAkhMX2nM1RniEQlrQrZzpScWEtr9o9M+b72nUyvO6PxDy3IPfNrd0+V/2C6uU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716983553; c=relaxed/simple; bh=Wjp4vrY9QLVw762XH4ypjxkMsMnlB9YnsIOMLhznYf8=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=li66xPmLyY1KnfAWLYzWvU7vqMU2iQqNexyUTQ6RSKLSEsGjUBwGe3WQRcl2GHUH+Sf+EbH8PwnKdQcN0zM0naTA3RuG7p1tj2LFrXfAtyYzQaAjG4iBEAbyAF4JoiEfADorJH19OnCIh52BBThrnSs2DMCudYnjWXPMEUiLa/k= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-529682e013dso2321285e87.3 for ; Wed, 29 May 2024 04:52:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716983550; x=1717588350; darn=gcc.gnu.org; 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=ZTZ4i81tQHPXOuZ7jAtoOARJZuo5YKqteZFtSZlbMxQ=; b=MTu+m9meWPeSVeb/5zqILi8jy1tlsIPKMEaHOUv/GzichL9JjNy9cmoDCvCoi0Ljqw dp/Vkg/rzb9nNRXXYl+7eO3dfRD5uxZlCMbFB0TvEH/O4YaUNtMNbcg1ij7eE5G8PV5A sx7xEtyhgSM9RT6k4HtMm3QRPRENXKo4bc2TdhbyRNP9oWg8e8H1hZhyBwZ0xduyapQT b2klyDpViypXg4AeDOmzE3XIgXKUWm8AFu+7m5MXsZ1MUbfChFtBtSbAcAzq8+EJVNmH WVAHDxRb05mAxSzHmMM/TcanPt8hdeqCxZG4T0KiXjy6WVhsEXba42E994PL32yU8QYs 7znA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716983550; x=1717588350; 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=ZTZ4i81tQHPXOuZ7jAtoOARJZuo5YKqteZFtSZlbMxQ=; b=ILQg/t9wxD3rzJfGuvSngPBHtof4cYl2KkxdnJsX3LOz73cBAymFvNp3hrIWCPSyOx gZNcWuOL9rbwI+7aqx78ANVCyN6KUVzQHlSaYIUn8vYC8G/6pY9/YJkTcrwSsQhJyKMi JYFXIb0oQPEdJ0Dcssx3K/vrFrDQyfCHrSc2EltwzF9b9Uyx5pYF5/CgFScsh3HfkQUW DiC78NXXEQHRPmePT/0efsp/GkMbESwUspeDJ0swfiBl/BL24OlTCsmiUXb3CLUziVEH E5oRCDEI67iLkjxyLiY4KGjHH9pPHcLoZen9iSkEsBQFnub2pcURC4ZvhEd/qz9aUKs1 Qnrw== X-Gm-Message-State: AOJu0Yx5QttfSXO2cKHzh/7fa6RokbkJkRf3gN4TdXpRom5YhdubIkY8 Y94eBt4Y7FvYvhjxJIQk8isX62fNjl/X/q+WoNm9b00B9GIlK5KlZhUCXRFa3hfHGDNcgdH7Wb+ Dk/08Ib/guxHodeKLHKYenxEHSgLP0A== X-Google-Smtp-Source: AGHT+IEaBhpNDOEWvdyEZYb/iPOpaYFi40iyRLOWNAUjCa3TFvXjsTDRfKX2NUSsjdCcfUcMI8qUcWCVFy8aZvKdyBI= X-Received: by 2002:ac2:5111:0:b0:51d:a1ca:5f26 with SMTP id 2adb3069b0e04-529649c5e5emr9576176e87.20.1716983549698; Wed, 29 May 2024 04:52:29 -0700 (PDT) MIME-Version: 1.0 References: <20240527004643.990621-1-quic_apinski@quicinc.com> In-Reply-To: <20240527004643.990621-1-quic_apinski@quicinc.com> From: Richard Biener Date: Wed, 29 May 2024 13:52:18 +0200 Message-ID: Subject: Re: [PATCH 1/2] Match: Add maybe_bit_not instead of plain matching To: Andrew Pinski Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.7 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 Mon, May 27, 2024 at 2:47=E2=80=AFAM Andrew Pinski wrote: > > While working on adding matching of negative expressions of `a - b`, > I noticed that we started to have "duplicated" patterns due to not having > a way to match maybe negative expressions. So I went back to what I did f= or > bit_not and decided to improve the situtation there so for some patterns > where we had 2 operands of an expression where one could have been a bit_= not, > add back maybe_bit_not. > This does not add maybe_bit_not in every place were bitwise_inverted_equa= l_p > is used, just the ones were 2 operands of an expression could be swapped. > > Bootstrapped and tested on x86_64-linux-gnu with no regressions. OK. Richard. > gcc/ChangeLog: > > * match.pd (bit_not_with_nop): Unconditionalize. > (maybe_cmp): Likewise. > (maybe_bit_not): New match pattern. > (`~X & X`): Use maybe_bit_not and add `:c` back. > (`~x ^ x`/`~x | x`): Likewise. > > Signed-off-by: Andrew Pinski > --- > gcc/match.pd | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/gcc/match.pd b/gcc/match.pd > index 024e3350465..090ad4e08b0 100644 > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -167,7 +167,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > TYPE_VECTOR_SUBPARTS (TREE_TYPE (@0))) > && tree_nop_conversion_p (TREE_TYPE (type), TREE_TYPE (TREE_TYPE (= @0)))))) > > -#if GIMPLE > /* These are used by gimple_bitwise_inverted_equal_p to simplify > detection of BIT_NOT and comparisons. */ > (match (bit_not_with_nop @0) > @@ -188,7 +187,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > (bit_xor@0 @1 @2) > (if (INTEGRAL_TYPE_P (type) > && TYPE_PRECISION (type) =3D=3D 1))) > -#endif > +/* maybe_bit_not is used to match what > + is acceptable for bitwise_inverted_equal_p. */ > +(match (maybe_bit_not @0) > + (bit_not_with_nop@0 @1)) > +(match (maybe_bit_not @0) > + (INTEGER_CST@0)) > +(match (maybe_bit_not @0) > + (maybe_cmp@0 @1)) > > /* Transform likes of (char) ABS_EXPR <(int) x> into (char) ABSU_EXPR > ABSU_EXPR returns unsigned absolute value of the operand and the oper= and > @@ -1332,7 +1338,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > > /* Simplify ~X & X as zero. */ > (simplify > - (bit_and (convert? @0) (convert? @1)) > + (bit_and:c (convert? @0) (convert? (maybe_bit_not @1))) > (with { bool wascmp; } > (if (types_match (TREE_TYPE (@0), TREE_TYPE (@1)) > && bitwise_inverted_equal_p (@0, @1, wascmp)) > @@ -1597,7 +1603,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > /* ~x ^ x -> -1 */ > (for op (bit_ior bit_xor) > (simplify > - (op (convert? @0) (convert? @1)) > + (op:c (convert? @0) (convert? (maybe_bit_not @1))) > (with { bool wascmp; } > (if (types_match (TREE_TYPE (@0), TREE_TYPE (@1)) > && bitwise_inverted_equal_p (@0, @1, wascmp)) > -- > 2.43.0 >