From: Diego Novillo <dnovillo@redhat.com>
To: Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
Cc: gcc@gcc.gnu.org
Subject: Re: Q about Ada and value ranges in types
Date: Tue, 03 May 2005 14:16:00 -0000 [thread overview]
Message-ID: <20050503141613.GA21050@topo.toronto.redhat.com> (raw)
In-Reply-To: <10505030146.AA26099@vlsi1.ultra.nyu.edu>
On Mon, May 02, 2005 at 09:46:59PM -0400, Richard Kenner wrote:
> 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.
>
Yeah, I didn't show all of it, sorry. My patch to address this
problem includes a more detailed description
(http://gcc.gnu.org/ml/gcc-patches/2005-05/msg00127.html).
Florian Weimer suggested that instead of marking the range as
varying, we could check the super-type to see if it has a wider
range. That is true in this case; the parent type is
types__Tname_idB which has range [-2147483648, 2147483647]. But
I'm not sure if that would be true in general.
> If the Ada language allows that kind of runtime check, then my
> fix to VRP will be different.
>
> I don't see it as a language issue: I'd argue that the tree in statement 2
> is invalid given the typing. That should be true for any language.
>
Dunno. All the operands in the snippet I showed are of the exact
same type (types__name_id___XDLU_300000000__399999999). I'm not
really sure where this type is coming from, but it's relatively
easy to reproduce.
Configure a compiler for target i386-pc-linux-gnu (or any other
i386 variant, not sure if it occurs elsewhere) and compile
ada/sem_intr.adb with:
$ ./xgcc -B./ -c -g -O2 -gnatpg -gnata -I- -I. -Iada -I<src>/gcc/ada <src>/gcc/ada/sem_intr.adb -o ada/sem_intr.o -v -save-temps
Launch gdb and set a bkpt at tree-vrp.c:552 (extract_range_from_assert).
You should get to this ASSERT_EXPR:
ASSERT_EXPR <D.1480_32, D.1480_32 <= 1>
which is in the following context:
-----------------------------------------------------------------------------
;; basic block 44, loop depth 0, count 0
;; prev block 43, next block 84
;; pred: 43 (true,exec)
;; succ: 84 (true,exec) 45 (false,exec)
<L51>:;
D.1478_28 = sinfo__etype (e_5);
nam_30 = sinfo__chars (e_5);
D.1480_32 = nam_30 - 300000361;
if (D.1480_32 <= 1) goto <L112>; else goto <L52>;
;; basic block 84, loop depth 0, count 0
;; prev block 44, next block 45
;; pred: 44 (true,exec)
;; succ: 50 [100.0%] (fallthru)
<L112>:;
D.1480_94 = ASSERT_EXPR <D.1480_32, D.1480_32 <= 1>;
goto <bb 50> (<L57>);
-----------------------------------------------------------------------------
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:
if Nam = Name_Op_Add
Thanks. Diego.
next prev parent reply other threads:[~2005-05-03 14:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-03 1:46 Richard Kenner
2005-05-03 14:16 ` Diego Novillo [this message]
-- strict thread matches above, loose matches on Subject: below --
2005-06-28 2:28 Richard Kenner
2005-06-27 20:48 Richard Kenner
2005-06-27 23:36 ` James A. Morrison
2005-05-03 22:20 Richard Kenner
2005-05-04 0:40 ` 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=20050503141613.GA21050@topo.toronto.redhat.com \
--to=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).