From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6120 invoked by alias); 23 Feb 2017 05:59:43 -0000 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 Received: (qmail 6098 invoked by uid 89); 23 Feb 2017 05:59:42 -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,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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; Thu, 23 Feb 2017 05:59:41 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 90A99C049D5D for ; Thu, 23 Feb 2017 05:59:41 +0000 (UTC) Received: from localhost.localdomain (ovpn-122-189.rdu2.redhat.com [10.10.122.189] (may be forged)) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1N5xeOx027253; Thu, 23 Feb 2017 00:59:41 -0500 Subject: Re: [PATCH] Optimize divmod expansion (PR middle-end/79665) To: Jakub Jelinek References: <20170222214046.GA1849@tucnak> Cc: gcc-patches@gcc.gnu.org From: Jeff Law Message-ID: Date: Thu, 23 Feb 2017 06:00:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170222214046.GA1849@tucnak> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-02/txt/msg01427.txt.bz2 On 02/22/2017 02:40 PM, Jakub Jelinek wrote: > Hi! > > If both arguments of integer division or modulo are known to be non-negative > in corresponding signed type, then signed as well as unsigned division/modulo > shall have the exact same result and therefore we can choose between those > two depending on which one is faster (or shorter for -Os), which varries > a lot depending on target and especially for constant divisors on the exact > divisor. expand_divmod itself is too complicated and we don't even have > the ability to ask about costs e.g. for highpart multiplication without > actually expanding it, so this patch just in that case tries both sequences, > computes their costs and uses the cheaper (and for equal cost honors the > actual original signedness of the operation). > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2017-02-22 Jakub Jelinek > > PR middle-end/79665 > * internal-fn.c (get_range_pos_neg): Moved to ... > * tree.c (get_range_pos_neg): ... here. No longer static. > * tree.h (get_range_pos_neg): New prototype. > * expr.c (expand_expr_real_2) : If both arguments > are known to be in between 0 and signed maximum inclusive, try to > expand both unsigned and signed divmod and use the cheaper one from > those. OK. jeff