From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32511 invoked by alias); 23 Jun 2010 17:48:36 -0000 Received: (qmail 32502 invoked by uid 22791); 23 Jun 2010 17:48:36 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,TW_IV,TW_OV,TW_VQ,TW_XT,TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-pv0-f175.google.com (HELO mail-pv0-f175.google.com) (74.125.83.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 23 Jun 2010 17:48:31 +0000 Received: by pvg3 with SMTP id 3so622880pvg.20 for ; Wed, 23 Jun 2010 10:48:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.143.26.19 with SMTP id d19mr7524610wfj.160.1277315310055; Wed, 23 Jun 2010 10:48:30 -0700 (PDT) Received: by 10.142.162.10 with HTTP; Wed, 23 Jun 2010 10:48:30 -0700 (PDT) In-Reply-To: <4C224592.5090100@gnu.org> References: <20100621193321.GA13780@intel.com> <1277229955.2613.1.camel@localhost> <1277232299.2613.13.camel@localhost> <4C224592.5090100@gnu.org> Date: Wed, 23 Jun 2010 18:46:00 -0000 Message-ID: Subject: Re: PATCH: PR target/44588: Very inefficient 8bit mod/div From: "H.J. Lu" To: Paolo Bonzini Cc: Uros Bizjak , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2010-06/txt/msg02358.txt.bz2 On Wed, Jun 23, 2010 at 10:34 AM, Paolo Bonzini wrote: > On 06/23/2010 04:26 PM, H.J. Lu wrote: >> >> On Tue, Jun 22, 2010 at 11:11 PM, Uros Bizjak =A0wrot= e: >>> >>> On Tue, Jun 22, 2010 at 8:57 PM, H.J. Lu =A0wrote: >>> >>>>>> If we use AX for quotient in 8bit divmod pattern, we have to make >>>>>> sure that AX is valid for quotient. =A0We have to extend AL with UNS= PEC >>>>>> since AH isn't the part of quotient,. =A0Instead, I use AL for quoti= ent >>>>>> and >>>>>> use UNSPEC_MOVQI_EXTZH to extract remainder from AL. Quotient >>>>>> access can be optimized very nicely. If remainder is used, we may ha= ve >>>>>> an extract move for UNSPEC_MOVQI_EXTZH. I think this is a reasonable >>>>>> comprise. >>>>> >>>>> Why we need to reinvent movqi_extzv_2 ? >>>> >>>> Because UNSPEC_MOVQI_EXTZH extracts AH from AL, not from >>>> AX, EAX, RAX. >>> >>> This is wrong, you can't extract AH out from AL... >> >> UNSPEC_MOVQI_EXTZH =A0is only used on AL from >> 8bit div where AH has remainder. Should I give it a different >> name, like UNSPEC_MOVQI_EXTZH_FROM_8BITDIV? >> >>>> >>>>> I guess thatdivqi3 has to be implemented as multiple-set divmod >>>>> pattern using strict_low_part subregs to exactly describe in which >>>>> subreg quotient and remainder go. >>>>> >>>> >>>> I tried it and couldn't get it to work without adding a new >>>> constraint for the upper 8bit registers. >>> >>> "Q" with %h modifier ? >>> >> >> Although there are AX, AL, AH, ......, the rest of compiler only >> knows one hard register, AX_REG, which is register 0. We can't >> really access upper 8bit register, =A0like AH, =A0as a real register. We >> can only access them via sign_extract and zero_extract. =A0As far >> as the rest of gcc is concerned, there are no upper 8bit registers. >> I don't think we can describe where 8bit div remainder is to the >> rest of compiler. > > Well, sure you can: > > (set (reg:HI r) > =A0 (ior:HI (lshift:HI > =A0 =A0 =A0 =A0 =A0 =A0(zero_extend:HI (umod:QI ...) (const_int 8))) > =A0 =A0 =A0 =A0 =A0 (zero_extend:HI (udiv:QI ...) (const_int 8)))) > > (set (reg:QI s) ;; remainder > =A0 (zero_extract (reg:HI r) (const_int 8) (const_int 8))) > > (set (reg:QI t) ;; quotient > =A0 (subreg (reg:HI r) 0)) > > The question is only whether fwprop, combine and regalloc are smart enough > to reason about it. > That is what I meant by "We can only access them via sign_extract and zero_extract." The rest of gcc will see the same hard register number for both lower and upper 8bit registers. They aren't prepared to deal with it. --=20 H.J.