From patchwork Thu Aug 9 20:27:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lawrence Crowl X-Patchwork-Id: 176269 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 1FA932C00B4 for ; Fri, 10 Aug 2012 06:27:53 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1345148874; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:To:Subject:Message-Id:Date: From:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=uSAQvfA i1TgGg1p7Eh3kMos+r6Y=; b=OUQPsdZU1YK2c0kWS589eN+A34unQOV8et0s4nX tDXoFyUCjCNMLveuRaUnuDL++pp6QWq6UYQthfayttEZJxmJ9IlFYX9pFMxo6jAy /fLZgYg7E7W2TazHDL3iE3tHBLRrOnPkxDEI9FjVPLEWtG/sp7dZCHjkt0OwIw/p TYtw= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:Received:Received:Received:To:Subject:Message-Id:Date:From:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=dAHb6dPuAiER/HwCIydGiUrYuadr8GMOiHLZKVdTpdz6caQofUxZsyn6LN28zS prc57W14pwfw1pDGN4KGURPnTBgmX6chN9dHuAd4cus87Nl6ibvJQNBwq0fITuLr +Gsk5DpOYD4GOntVFcHpUXLTtwpL6qa7+W7zP3w2DMHwU=; Received: (qmail 26332 invoked by alias); 9 Aug 2012 20:27:47 -0000 Received: (qmail 26324 invoked by uid 22791); 9 Aug 2012 20:27:46 -0000 X-SWARE-Spam-Status: No, hits=-4.1 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, T_RP_MATCHES_RCVD, URIBL_DBL_REDIR X-Spam-Check-By: sourceware.org Received: from mail-ee0-f73.google.com (HELO mail-ee0-f73.google.com) (74.125.83.73) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 09 Aug 2012 20:27:32 +0000 Received: by eeke49 with SMTP id e49so40829eek.2 for ; Thu, 09 Aug 2012 13:27:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=to:subject:message-id:date:from:x-gm-message-state; bh=87//Gq99RqC11CpemnatKwSkii8qPvhy7e2ivPn0qPs=; b=DVRvVFC44gXaZz8duhp/e8YXwOZH3h/bq3dobIs+LdP6LmaOKCsXj3sr/L0DWgv0b8 Ej5aOs6zh50AUAsANzU+fRPtZmUfYfpIbFVJlfQ5wUjbHdehcNUqytIL4l0gMROLo5e+ YR2AA98GsfHMmrD+AMLrL7qTQEZ1ILmnXgAhHPwzThExVRTRRc9aB3beK/HiWywySGFS CMHZuSynE7Bf+E4LGD/FKPlWlPVaPahadoZKd5IZAxxEKDeBB0hg7HTItSFhBSyEBY+M zug1MTtjF62FNXIqzdE6CEtqQbbu7nmqCP/If3Hw9QSDEtDl6F5UQp+FJXPHPY2IyAr4 Xfiw== Received: by 10.14.179.72 with SMTP id g48mr652848eem.2.1344544051124; Thu, 09 Aug 2012 13:27:31 -0700 (PDT) Received: by 10.14.179.72 with SMTP id g48mr652841eem.2.1344544051057; Thu, 09 Aug 2012 13:27:31 -0700 (PDT) Received: from hpza9.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id 46si2808731eed.1.2012.08.09.13.27.31 (version=TLSv1/SSLv3 cipher=AES128-SHA); Thu, 09 Aug 2012 13:27:31 -0700 (PDT) Received: from jade.mtv.corp.google.com (jade.mtv.corp.google.com [172.18.110.116]) by hpza9.eem.corp.google.com (Postfix) with ESMTP id AC2D55C0050; Thu, 9 Aug 2012 13:27:30 -0700 (PDT) Received: by jade.mtv.corp.google.com (Postfix, from userid 21482) id 089062226D9; Thu, 9 Aug 2012 13:27:29 -0700 (PDT) To: reply@codereview.appspotmail.com, dnovillo@google.com, gcc-patches@gcc.gnu.org Subject: [cxx-conversion] Avoid overloaded double_int 'constructor'. (issue6441127) Message-Id: <20120809202730.089062226D9@jade.mtv.corp.google.com> Date: Thu, 9 Aug 2012 13:27:29 -0700 (PDT) From: crowl@google.com (Lawrence Crowl) X-Gm-Message-State: ALoCoQka2XyNU4n+RwwUceXU53zCvOKfi2WOBvKboLWZuk+N9xwwCx+S/DdUrIpLbJtuQPnQnL8EI2o84pE5loltvzzsV2AGaUNq6sJ7eUV6SMWEz4T9uVsi6oCSs5jnfbgQXWlao2y5Z1cp4i8NrWA1Mv+N5HpMdMGifnjBtz0kqNVNnszESWPzpFvyWJsINAoNJH03eDnH X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Convert overloaded double_int::make to non-overloaded from_signed and from_unsigned. This change is intended to preserve the exact semantics of the existing expressions using shwi_to_double_int and uhwi_to_double_int. Tested on x86_64. --- This patch is available for review at http://codereview.appspot.com/6441127 Index: gcc/ChangeLog 2012-08-09 Lawrence Crowl * double-int.h (double_int::make): Remove. (double_int::from_signed): New. (double_int::from_unsigned): New. (shwi_to_double_int): Use double_int::from_signed instead of double_int::make. (double_int_minus_one): Likewise. (double_int_zero): Likewise. (double_int_one): Likewise. (double_int_two): Likewise. (double_int_ten): Likewise. (uhwi_to_double_int): Use double_int::from_unsigned instead of double_int::make. Index: gcc/double-int.h =================================================================== --- gcc/double-int.h (revision 190239) +++ gcc/double-int.h (working copy) @@ -60,10 +60,8 @@ public: Second, the GCC conding conventions prefer explicit conversion, and explicit conversion operators are not available until C++11. */ - static double_int make (unsigned HOST_WIDE_INT cst); - static double_int make (HOST_WIDE_INT cst); - static double_int make (unsigned int cst); - static double_int make (int cst); + static double_int from_unsigned (unsigned HOST_WIDE_INT cst); + static double_int from_signed (HOST_WIDE_INT cst); /* No copy assignment operator or destructor to keep the type a POD. */ @@ -188,7 +186,7 @@ public: HOST_WIDE_INT are filled with the sign bit. */ inline -double_int double_int::make (HOST_WIDE_INT cst) +double_int double_int::from_signed (HOST_WIDE_INT cst) { double_int r; r.low = (unsigned HOST_WIDE_INT) cst; @@ -196,17 +194,11 @@ double_int double_int::make (HOST_WIDE_I return r; } -inline -double_int double_int::make (int cst) -{ - return double_int::make (static_cast (cst)); -} - /* FIXME(crowl): Remove after converting callers. */ static inline double_int shwi_to_double_int (HOST_WIDE_INT cst) { - return double_int::make (cst); + return double_int::from_signed (cst); } /* Some useful constants. */ @@ -214,17 +206,17 @@ shwi_to_double_int (HOST_WIDE_INT cst) The problem is that a named constant would not be as optimizable, while the functional syntax is more verbose. */ -#define double_int_minus_one (double_int::make (-1)) -#define double_int_zero (double_int::make (0)) -#define double_int_one (double_int::make (1)) -#define double_int_two (double_int::make (2)) -#define double_int_ten (double_int::make (10)) +#define double_int_minus_one (double_int::from_signed (-1)) +#define double_int_zero (double_int::from_signed (0)) +#define double_int_one (double_int::from_signed (1)) +#define double_int_two (double_int::from_signed (2)) +#define double_int_ten (double_int::from_signed (10)) /* Constructs double_int from unsigned integer CST. The bits over the precision of HOST_WIDE_INT are filled with zeros. */ inline -double_int double_int::make (unsigned HOST_WIDE_INT cst) +double_int double_int::from_unsigned (unsigned HOST_WIDE_INT cst) { double_int r; r.low = cst; @@ -232,17 +224,11 @@ double_int double_int::make (unsigned HO return r; } -inline -double_int double_int::make (unsigned int cst) -{ - return double_int::make (static_cast (cst)); -} - /* FIXME(crowl): Remove after converting callers. */ static inline double_int uhwi_to_double_int (unsigned HOST_WIDE_INT cst) { - return double_int::make (cst); + return double_int::from_unsigned (cst); } inline double_int &