From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8809 invoked by alias); 7 May 2010 20:31:42 -0000 Received: (qmail 8596 invoked by uid 22791); 7 May 2010 20:31:35 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SARE_MSGID_LONG45,TW_JC X-Spam-Check-By: sourceware.org Received: from mail-gy0-f175.google.com (HELO mail-gy0-f175.google.com) (209.85.160.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 07 May 2010 20:31:29 +0000 Received: by gya1 with SMTP id 1so865085gya.20 for ; Fri, 07 May 2010 13:31:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.150.141.2 with SMTP id o2mr3966553ybd.332.1273264287435; Fri, 07 May 2010 13:31:27 -0700 (PDT) Received: by 10.151.11.21 with HTTP; Fri, 7 May 2010 13:31:27 -0700 (PDT) In-Reply-To: <1811669158.20100507225908@post.ru> References: <1811669158.20100507225908@post.ru> Date: Fri, 07 May 2010 20:31:00 -0000 Message-ID: Subject: Re: Remove build_int_cst_wide_type function. From: Richard Guenther To: Anatoly Sokolov Cc: gcc-patches@gcc.gnu.org, java-patches@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Mailing-List: contact java-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-patches-owner@gcc.gnu.org X-SW-Source: 2010-q2/txt/msg00014.txt.bz2 2010/5/7 Anatoly Sokolov : > Hello. > > > =A0The build_int_cst_wide_type and double_int_to_tree functions do the sa= me > work but differ only in argument types. The build_int_cst_wide_type get > INT_CST as doule_int type, build_int_cst_wide_type as pair HOST_WIDE_INT. > This patch change all uses build_int_cst_wide_type with double_int_to_tre= e and > remove build_int_cst_wide_type function. > > =A0Bootstrapped/regtested on x86_64-unknown-linux-gnu for c, c++ and java. > > =A0OK for mainline? Comments inline > =A0 =A0 =A0 =A0* double-int.h (double_int_ior): New function. > =A0 =A0 =A0 =A0* tree.h (build_int_cst_wide_type): Remove. > =A0 =A0 =A0 =A0* tree.c (build_int_cst_wide_type): Remove. > =A0 =A0 =A0 =A0(double_int_to_tree, double_int_fits_to_tree_p): Handle si= ze types as > =A0 =A0 =A0 =A0sign extended. > =A0 =A0 =A0 =A0* fold-const.c (native_interpret_int): Use double_int_to_t= ree instead > =A0 =A0 =A0 =A0of build_int_cst_wide_type. > =A0 =A0 =A0 =A0* dojump.c (do_jump): (Ditto.). > =A0 =A0 =A0 =A0* stor-layout.c (set_sizetype): (Ditto.). > > /java > =A0 =A0 =A0 =A0* jcf-parse.c (get_constant): Use double_int_to_tree inste= ad of > =A0 =A0 =A0 =A0build_int_cst_wide_type. > > > Index: gcc/java/jcf-parse.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- gcc/java/jcf-parse.c =A0 =A0 =A0 =A0(revision 159109) > +++ gcc/java/jcf-parse.c =A0 =A0 =A0 =A0(working copy) > @@ -1040,14 +1040,15 @@ > =A0 =A0 =A0 } > =A0 =A0 case CONSTANT_Long: > =A0 =A0 =A0 { > - =A0 =A0 =A0 unsigned HOST_WIDE_INT num =3D JPOOL_UINT (jcf, index); > - =A0 =A0 =A0 unsigned HOST_WIDE_INT lo; > - =A0 =A0 =A0 HOST_WIDE_INT hi; > - > - =A0 =A0 =A0 lshift_double (num, 0, 32, 64, &lo, &hi, 0); > - =A0 =A0 =A0 num =3D JPOOL_UINT (jcf, index+1); > - =A0 =A0 =A0 add_double (lo, hi, num, 0, &lo, &hi); > - =A0 =A0 =A0 value =3D build_int_cst_wide_type (long_type_node, lo, hi); > + =A0 =A0 =A0 unsigned HOST_WIDE_INT num; > + =A0 =A0 =A0 double_int val; > + > + =A0 =A0 =A0 num =3D JPOOL_UINT (jcf, index); > + =A0 =A0 =A0 val =3D double_int_lshift (uhwi_to_double_int (num), 32, 64= , false); > + =A0 =A0 =A0 num =3D JPOOL_UINT (jcf, index + 1); > + =A0 =A0 =A0 val =3D double_int_ior (val, uhwi_to_double_int (num)); > + > + =A0 =A0 =A0 value =3D double_int_to_tree (long_type_node, val); > =A0 =A0 =A0 =A0break; > =A0 =A0 =A0 } > > Index: gcc/tree.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- gcc/tree.c =A0(revision 159109) > +++ gcc/tree.c =A0(working copy) > @@ -1071,25 +1071,19 @@ > =A0 return build_int_cst_wide (type, low1, hi); > =A0} > > -/* Create an INT_CST node of TYPE and value HI:LOW. =A0The value is trun= cated > - =A0 and sign extended according to the value range of TYPE. =A0*/ > - > -tree > -build_int_cst_wide_type (tree type, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0unsigned HOST_WIDE_INT l= ow, HOST_WIDE_INT high) > -{ > - =A0fit_double_type (low, high, &low, &high, type); > - =A0return build_int_cst_wide (type, low, high); > -} > - > =A0/* Constructs tree in type TYPE from with value given by CST. =A0Signe= dness > =A0 =A0of CST is assumed to be the same as the signedness of TYPE. =A0*/ > > =A0tree > =A0double_int_to_tree (tree type, double_int cst) > =A0{ > - =A0cst =3D double_int_ext (cst, TYPE_PRECISION (type), TYPE_UNSIGNED (t= ype)); > + =A0/* Size types *are* sign extended. =A0*/ > + =A0bool sign_extended_type =3D (!TYPE_UNSIGNED (type) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0|| (TREE_CODE (t= ype) =3D=3D INTEGER_TYPE > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&& TYPE_= IS_SIZETYPE (type))); whoops - thanks for catching this. > + =A0cst =3D double_int_ext (cst, TYPE_PRECISION (type), !sign_extended_t= ype); > + > =A0 return build_int_cst_wide (type, cst.low, cst.high); > =A0} > > @@ -1099,10 +1093,14 @@ > =A0bool > =A0double_int_fits_to_tree_p (const_tree type, double_int cst) > =A0{ > - =A0double_int ext =3D double_int_ext (cst, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0TYPE= _PRECISION (type), > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0TYPE= _UNSIGNED (type)); > + =A0/* Size types *are* sign extended. =A0*/ > + =A0bool sign_extended_type =3D (!TYPE_UNSIGNED (type) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0|| (TREE_CODE (t= ype) =3D=3D INTEGER_TYPE > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&& TYPE_= IS_SIZETYPE (type))); > > + =A0double_int ext > + =A0 =A0=3D double_int_ext (cst, TYPE_PRECISION (type), !sign_extended_t= ype); > + > =A0 return double_int_equal_p (cst, ext); > =A0} > > Index: gcc/tree.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- gcc/tree.h =A0(revision 159109) > +++ gcc/tree.h =A0(working copy) > @@ -4013,8 +4013,6 @@ > =A0extern tree build_int_cst_type (tree, HOST_WIDE_INT); > =A0extern tree build_int_cstu (tree, unsigned HOST_WIDE_INT); > =A0extern tree build_int_cst_wide (tree, unsigned HOST_WIDE_INT, HOST_WID= E_INT); > -extern tree build_int_cst_wide_type (tree, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= unsigned HOST_WIDE_INT, HOST_WIDE_INT); > =A0extern tree build_vector (tree, tree); > =A0extern tree build_vector_from_ctor (tree, VEC(constructor_elt,gc) *); > =A0extern tree build_constructor (tree, VEC(constructor_elt,gc) *); > Index: gcc/fold-const.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- gcc/fold-const.c =A0 =A0(revision 159109) > +++ gcc/fold-const.c =A0 =A0(working copy) > @@ -7408,13 +7408,14 @@ > =A0 int total_bytes =3D GET_MODE_SIZE (TYPE_MODE (type)); > =A0 int byte, offset, word, words; > =A0 unsigned char value; > - =A0unsigned int HOST_WIDE_INT lo =3D 0; > - =A0HOST_WIDE_INT hi =3D 0; > + =A0double_int result; > > =A0 if (total_bytes > len) > =A0 =A0 return NULL_TREE; > =A0 if (total_bytes * BITS_PER_UNIT > 2 * HOST_BITS_PER_WIDE_INT) > =A0 =A0 return NULL_TREE; > + > + =A0result =3D double_int_zero; > =A0 words =3D total_bytes / UNITS_PER_WORD; > > =A0 for (byte =3D 0; byte < total_bytes; byte++) > @@ -7436,13 +7437,13 @@ > =A0 =A0 =A0 value =3D ptr[offset]; > > =A0 =A0 =A0 if (bitpos < HOST_BITS_PER_WIDE_INT) > - =A0 =A0 =A0 lo |=3D (unsigned HOST_WIDE_INT) value << bitpos; > + =A0 =A0 =A0 result.low |=3D (unsigned HOST_WIDE_INT) value << bitpos; > =A0 =A0 =A0 else > - =A0 =A0 =A0 hi |=3D (unsigned HOST_WIDE_INT) value > - =A0 =A0 =A0 =A0 =A0 =A0 << (bitpos - HOST_BITS_PER_WIDE_INT); > + =A0 =A0 =A0 result.high |=3D (unsigned HOST_WIDE_INT) value > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<< (bitpos - HOST_BITS_PER_W= IDE_INT); > =A0 =A0 } > > - =A0return build_int_cst_wide_type (type, lo, hi); > + =A0return double_int_to_tree (type, result); > =A0} > > > Index: gcc/dojump.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- gcc/dojump.c =A0 =A0 =A0 =A0(revision 159109) > +++ gcc/dojump.c =A0 =A0 =A0 =A0(working copy) > @@ -539,10 +539,11 @@ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&& prefer_and_bit_test (TYPE_MODE (arg= type), > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0TREE_INT_CST_LOW (shift))) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{ > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 unsigned HOST_WIDE_INT mask > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =3D (unsigned HOST_WIDE_INT) 1 << T= REE_INT_CST_LOW (shift); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 double_int mask > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =3D double_int_setbit (double_int_z= ero, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0TREE_INT_CST_LOW (shift)); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0do_jump (build2 (BIT_AND_EXPR, argtype= , arg, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0buil= d_int_cst_wide_type (argtype, mask, 0)), > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0doub= le_int_to_tree (argtype, mask)), Use build_int_cstu instead and retain using HOST_WIDE_INTs. Btw, both build_int_cst and build_int_cstu should do proper sign/zero extension as the types precision may be lower than that of HOST_WIDE_INT. > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 clr_label, set_label,= setclr_prob); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > Index: gcc/double-int.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- gcc/double-int.h =A0 =A0(revision 159109) > +++ gcc/double-int.h =A0 =A0(working copy) > @@ -126,6 +126,7 @@ > =A0double_int double_int_setbit (double_int, unsigned); > > =A0/* Logical operations. =A0*/ > + > =A0static inline double_int > =A0double_int_not (double_int a) > =A0{ > @@ -134,6 +135,14 @@ > =A0 return a; > =A0} > > +static inline double_int > +double_int_ior (double_int a, double_int b) > +{ > + =A0a.low |=3D b.low; > + =A0a.high |=3D b.high; > + =A0return a; > +} > + > =A0/* Shift operations. =A0*/ > =A0double_int double_int_lshift (double_int, HOST_WIDE_INT, unsigned int,= bool); > =A0double_int double_int_rshift (double_int, HOST_WIDE_INT, unsigned int,= bool); > Index: gcc/stor-layout.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- gcc/stor-layout.c =A0 (revision 159109) > +++ gcc/stor-layout.c =A0 (working copy) > @@ -2275,9 +2275,7 @@ > =A0 =A0 =A0sign-extended in a way consistent with force_fit_type. =A0*/ > =A0 max =3D TYPE_MAX_VALUE (sizetype); > =A0 TYPE_MAX_VALUE (sizetype) > - =A0 =A0=3D build_int_cst_wide_type (sizetype, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0TREE_INT_CST= _LOW (max), > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0TREE_INT_CST= _HIGH (max)); > + =A0 =A0=3D double_int_to_tree (sizetype, tree_to_double_int (max)); Ok with these changes. Thanks, Richard.