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 471A53857C53 for ; Mon, 10 Aug 2020 08:39:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 471A53857C53 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-194-8d0zgfefOae-VkbyJpAQNw-1; Mon, 10 Aug 2020 04:39:10 -0400 X-MC-Unique: 8d0zgfefOae-VkbyJpAQNw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 208D58015F0; Mon, 10 Aug 2020 08:39:09 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-113-174.ams2.redhat.com [10.36.113.174]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AD11160BE2; Mon, 10 Aug 2020 08:39:08 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id 07A8d5GZ030132; Mon, 10 Aug 2020 10:39:06 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 07A8d48w030131; Mon, 10 Aug 2020 10:39:04 +0200 Date: Mon, 10 Aug 2020 10:39:04 +0200 From: Jakub Jelinek To: Marc Glisse Cc: gcc-patches@gcc.gnu.org Subject: Re: Simplify X * C1 == C2 with wrapping overflow Message-ID: <20200810083904.GU2363@tucnak> Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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=-7.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, 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: Mon, 10 Aug 2020 08:39:15 -0000 On Sun, Aug 09, 2020 at 11:24:54PM +0200, Marc Glisse wrote: > Odd numbers are invertible in Z / 2^n Z, so X * C1 == C2 can be rewritten as > X == C2 * inv(C1) when overflow wraps. > > mod_inv should probably be updated to better match the other wide_int > functions, but that's a separate issue. > > Bootstrap+regtest on x86_64-pc-linux-gnu. > > 2020-08-10 Marc Glisse > > PR tree-optimization/95433 > * match.pd (X * C1 == C2): Handle wrapping overflow. > * expr.c (maybe_optimize_mod_cmp): Qualify call to mod_inv. > (mod_inv): Move... > * wide-int.cc (mod_inv): ... here. > * wide-int.h (mod_inv): Declare it. > > * gcc.dg/tree-ssa/pr95433-2.c: New file. LGTM, thanks. Jakub