public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: ja2morri@csclub.uwaterloo.ca (James A. Morrison)
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
Date: Mon, 27 Jun 2005 23:36:00 -0000	[thread overview]
Message-ID: <kfh3br3z82e.fsf@csclub.uwaterloo.ca> (raw)
In-Reply-To: <10506272049.AA09083@vlsi1.ultra.nyu.edu>


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

  reply	other threads:[~2005-06-27 23:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-27 20:48 Richard Kenner
2005-06-27 23:36 ` James A. Morrison [this message]
  -- strict thread matches above, loose matches on Subject: below --
2005-06-28  2:28 Richard Kenner
2005-05-03 22:20 Richard Kenner
2005-05-04  0:40 ` Diego Novillo
2005-05-03  1:46 Richard Kenner
2005-05-03 14:16 ` Diego Novillo
2005-05-02 15:26 Diego Novillo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=kfh3br3z82e.fsf@csclub.uwaterloo.ca \
    --to=ja2morri@csclub.uwaterloo.ca \
    --cc=dnovillo@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=kenner@vlsi1.ultra.nyu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).