From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33221 invoked by alias); 20 Jun 2018 05:16:41 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 33210 invoked by uid 89); 20 Jun 2018 05:16:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=majority, vast, Hx-languages-length:1241, H*i:sk:65296BE X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Jun 2018 05:16:39 +0000 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49D01308A956; Wed, 20 Jun 2018 05:16:38 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-2.rdu2.redhat.com [10.10.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 364C0100190D; Wed, 20 Jun 2018 05:16:36 +0000 (UTC) Subject: Re: divmod pattern question To: Paul Koning , GCC Development References: <65296BEC-0850-41E8-A5D0-FC8FFA4C17E5@comcast.net> From: Jeff Law Openpgp: preference=signencrypt Message-ID: <28179a1c-01b8-a99b-fefd-cf75fcdff2fc@redhat.com> Date: Wed, 20 Jun 2018 05:31:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <65296BEC-0850-41E8-A5D0-FC8FFA4C17E5@comcast.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2018-06/txt/msg00209.txt.bz2 On 06/19/2018 12:55 PM, Paul Koning wrote: > Gentlepeople, > > I have a two-operand divide instruction that takes a double length dividend in a register pair, and produces the quotient in the first register and remainder in the second. > > How do I write a divmod pattern for that? The quotient is easy enough, I write a match_operand for that register and a matching constraint ("0") for the input dividend. But what about the remainder? The remainder appears in a register that isn't explicitly mentioned in the RTL (it's the regnum one higher than the quotient, or if you like, the second subreg of the input (dividend) register. You can generally allocate double-sized registers with appropriate constraints and the like. And you could use matching constraints, perhaps with subregs, but in the end, ewwwww. > > I can make it a define_expand that adds a move from the remainder register into a new register which is the output operand, and count on the optimizer to optimize away that move. Is that the best answer? The current "mod" pattern does that, and I could keep that approach. But this would generally be better I think. I'd expect the move to be optimized away the vast majority of the time. jeff