From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 25D503854800 for ; Fri, 15 Jan 2021 20:04:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 25D503854800 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-476-vQC_5wRSNOOjxFNNg-jwGg-1; Fri, 15 Jan 2021 15:04:03 -0500 X-MC-Unique: vQC_5wRSNOOjxFNNg-jwGg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3BDAF8799F9; Fri, 15 Jan 2021 20:04:02 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-112-64.ams2.redhat.com [10.36.112.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C94D45D9C6; Fri, 15 Jan 2021 20:04:01 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 10FK3x3R3967434 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 15 Jan 2021 21:03:59 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 10FK3wMt3967433; Fri, 15 Jan 2021 21:03:58 +0100 Date: Fri, 15 Jan 2021 21:03:58 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] match.pd: Generalize the PR64309 simplifications [PR96669] Message-ID: <20210115200358.GP1034503@tucnak> Reply-To: Jakub Jelinek References: <20210115183835.GN1034503@tucnak> <3A093C96-8989-4882-B774-AD39DDEBCAA4@suse.de> MIME-Version: 1.0 In-Reply-To: <3A093C96-8989-4882-B774-AD39DDEBCAA4@suse.de> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jan 2021 20:04:07 -0000 On Fri, Jan 15, 2021 at 08:50:20PM +0100, Richard Biener wrote: > On January 15, 2021 7:38:35 PM GMT+01:00, Jakub Jelinek wrote: > >Hi! > > > >The following patch generalizes the PR64309 simplifications, so that > >instead > >of working only with constants 1 and 1 it works with any two power of > >two > >constants, and works also for right shift (in that case it rules out > >the > >first one being negative, as it is arithmetic shift then). > > > >Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > Ok. Thanks. BTW, I've tried to also fix what the PR wanted primarily by adding /* Simplify (CST << x) & 1 to 0 if CST is even or to x == 0 if it is odd. / (simplify (bit_and (lshift INTEGER_CST@1 @0) integer_onep) (if ((wi::to_wide (@1) & 1) != 0) (eq @0 { build_zero_cst (TREE_TYPE (@0)); }) ({ build_zero_cst (type); }))) simplifier before this one, but genmatch.c doesn't seem to put it into the resulting files. Is there a way to figure out what is going on? I remember you said one can't have multiple too similar rules, but the closest one I can find is (for shift (lshift rshift) (simplify (bit_and (convert?:s@4 (shift:s@5 (convert1?@3 @0) INTEGER_CST@1)) INTEGER_CST@2) Is it that one that makes the above not work and shall I then stick it into the same simplifier? What I want has the @1 in this one actually not an INTEGER_CST, while @3 shall be INTEGER_CST... Jakub