From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15956 invoked by alias); 27 Jun 2005 23:36:18 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 15942 invoked by uid 22791); 27 Jun 2005 23:36:11 -0000 Received: from perpugilliam.csclub.uwaterloo.ca (HELO perpugilliam.csclub.uwaterloo.ca) (129.97.134.31) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Mon, 27 Jun 2005 23:36:11 +0000 Received: by perpugilliam.csclub.uwaterloo.ca (Postfix, from userid 20178) id C6667A85F8; Mon, 27 Jun 2005 19:36:09 -0400 (EDT) To: kenner@vlsi1.ultra.nyu.edu (Richard Kenner) Cc: dnovillo@redhat.com, gcc@gcc.gnu.org Subject: Re: Q about Ada and value ranges in types References: <10506272049.AA09083@vlsi1.ultra.nyu.edu> From: ja2morri@csclub.uwaterloo.ca (James A. Morrison) Date: Mon, 27 Jun 2005 23:36:00 -0000 In-Reply-To: <10506272049.AA09083@vlsi1.ultra.nyu.edu> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2005-06/txt/msg01067.txt.bz2 kenner@vlsi1.ultra.nyu.edu (Richard Kenner) writes: > Sorry it took me so long to get to this. > > > You're not showing where this comes from, so it's hard to say. However > > D.1480 is created by the gimplifier, not the Ada front end. There could > > easily be a typing problem in the tree there (e.g., that of the > > subtraction) but I can't tell for sure. > > As it turned out, there was. > > So, after calling sinfo__chars() and subtracting 300000361, the > FE is emitting that range check. AFAICT, the call to > sinfo__chars(e_5) comes from ada/sem_intr.adb:148 > > Nam : constant Name_Id := Chars (E); > > and 'if (D.1480_32 <= 1)' is at line 155: > > I'd also assumed this was where the bogus tree came from, but I was wrong. > The node in question was not made by the Ada front end but by > build_range_check in clearly incorrect code that does the subtraction in the > wrong type. > > This fixes that problem. Are you in a position to check if it fixes the > original issue? > > *** fold-const.c 25 Jun 2005 01:59:57 -0000 1.599 > --- fold-const.c 27 Jun 2005 20:44:56 -0000 > *************** build_range_check (tree type, tree exp, > *** 4027,4034 **** > > if (value != 0 && ! TREE_OVERFLOW (value)) > ! return build_range_check (type, > ! fold_build2 (MINUS_EXPR, etype, exp, low), > ! 1, fold_convert (etype, integer_zero_node), > ! value); > > return 0; > --- 4027,4045 ---- > > if (value != 0 && ! TREE_OVERFLOW (value)) > ! { > ! /* There is no requirement that LOW be within the range of ETYPE > ! if the latter is a subtype. It must, however, be within the base > ! type of ETYPE. So be sure we do the subtraction in that type. */ > ! if (TREE_TYPE (etype)) > ! { > ! etype = TREE_TYPE (etype); > ! value = fold_convert (etype, value); > ! } > ! > ! return build_range_check (type, > ! fold_build2 (MINUS_EXPR, etype, exp, low), > ! 1, fold_convert (etype, integer_zero_node), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RTH has been suggesting to use build_int_cst (etype, 0) instead. > ! value); > ! } > > return 0; > -- Thanks, Jim http://www.csclub.uwaterloo.ca/~ja2morri/ http://phython.blogspot.com http://open.nit.ca/wiki/?page=jim