public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "baldrick at free dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ada/26797] [4.3 regression] ACATS cxh1001 fails
Date: Fri, 09 Mar 2007 10:41:00 -0000	[thread overview]
Message-ID: <20070309104118.22864.qmail@sourceware.org> (raw)
In-Reply-To: <bug-26797-7210@http.gcc.gnu.org/bugzilla/>



------- Comment #29 from baldrick at free dot fr  2007-03-09 10:41 -------
Subject: Re:  [4.3 regression] ACATS cxh1001 fails

> > Sure, it's just that overloading V_C_E like this feels somehow wrong to me.
> 
> Why?  It's not "overloading".  V_C_E of an expression E of type X to
> type Y means "interpret the bits of E as if it were type Y and not type X".
> If Y is X'Base, then interpreting E as being Y means that it can now have
> all the values of Y.

For example, after the view conversion it is legal to place a value in it that
is in the range of Y but not of X.  This is logical.  What seems illogical to
me is that by doing the V_C_E you are supposed to forget anything you had
deduced about the bits before the conversion.  For example, suppose you had
deduced that the bits were all zero.  After the V_C_E the bits will still be
zero - are you really supposed to forget this information?  Another example:
suppose you had worked out somehow that the bits corresponded to an integer
in the range 4..5.  After the V_C_E this is still true - why is it logical
to forget this information?  You may well respond that you are only supposed
to forget information you deduced from the range of the type, not information
you worked out by some other means.  But these cannot really be distinguished,
c.f. VRP.

In short, it is overloading because it means: consider this bunch of bits
to be of the new type AND forget anything you ever deduced about them.

> In other words, we could only change a V_C_E to a 
> NOP_EXPR if we can prove that the value of E is in range of *both* X
> and Y.

Surely you only have to prove that it is in the range of Y, since if it
is not in the range of X then you have a bounded error, and doing a NOP_EXPR
should be perfectly legal.

> Of course, we still have a bit of a mess here in that the real point is
> a confusion between what in Ada is called a Bounded Error and C's notion
> of "undefined" (Ada's "erroneous").  But I think we can do better in this
> area: we just haven't gotten to take a really good look at it.
> 
> > However I haven't been able to put my finger on any technical obstacle to
> > this use of V_C_E.
> 
> Nor can I ...

Actually I do have a technical objection, however it comes from my LLVM
port and not mainline gcc.  LLVM is lower level than gimple.  Supposing
types X and Y have eg 32 bits, then they both get mapped to LLVM's Int32
type.  A V_C_E gets turned into nothing at all.  There are no types with
restricted ranges.  Suppose x is a variable of type X.  When a value is
loaded into x I'm planning on generating the following LLVM code:
        x = value;
        assert(x >= lower_bound_for_gcc_type && x <= upper_bound_for_gcc_type);
I don't generate the assert when you do a V_C_E, so for example suppose there
is a y = V_C_E(Y, x).  This gets turned into:
        y = x;
Since the optimizers have range info for x, they instantly deduce the same
ranges for y as for x.  Thus if you test for validity of y using
        valid = (y >= lower_bound_for_gcc_type_X && y <=
upper_bound_for_gcc_type-X);
then the result is always true.  How to get around this?  The obvious method is
to
use an intrinsic, such as __builtin_nop.  For the V_C_E I can then do:
        y = __builtin_nop(x);
and all will be well.  However, I only really need to use the __builtin_nop if
I'm doing the V_C_E in order to implement 'Valid.  For other uses of V_C_E it
is unnecessary and gets in the way of optimization.  So I would much rather
that
'Valid directly made use of a builtin.

Ciao,

Duncan.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26797


  parent reply	other threads:[~2007-03-09 10:41 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-22  7:29 [Bug ada/26797] New: [4.2 Regression] ACATS c35507m cd2a23e cxh1001 wrong code laurent at guerby dot net
2006-03-22 10:33 ` [Bug ada/26797] " ebotcazou at gcc dot gnu dot org
2006-03-22 18:48 ` [Bug ada/26797] [4.2 Regression] ACATS c35507m cd2a23e cxh1001 failures ebotcazou at gcc dot gnu dot org
2006-03-22 21:08 ` pinskia at gcc dot gnu dot org
2006-03-23 13:19 ` [Bug tree-optimization/26797] " baldrick at free dot fr
2006-03-27 17:09 ` law at redhat dot com
2006-03-27 17:23 ` law at redhat dot com
2006-03-27 20:12 ` laurent at guerby dot net
2006-03-27 20:31 ` law at redhat dot com
2006-03-28  3:56 ` kenner at vlsi1 dot ultra dot nyu dot edu
2006-03-28 15:01 ` law at redhat dot com
2006-03-28 15:33 ` law at redhat dot com
2006-03-30  7:58 ` ebotcazou at gcc dot gnu dot org
2006-03-30  8:25 ` ebotcazou at gcc dot gnu dot org
2006-03-30  8:32 ` ebotcazou at gcc dot gnu dot org
2006-03-30 12:13 ` kenner at vlsi1 dot ultra dot nyu dot edu
2006-04-21 23:40 ` [Bug tree-optimization/26797] [4.2 Regression] ACATS c35507m cd2a23e cxh1001 fail pinskia at gcc dot gnu dot org
2006-04-21 23:41 ` pinskia at gcc dot gnu dot org
2006-04-21 23:41 ` pinskia at gcc dot gnu dot org
2006-06-04  8:27 ` christian dot joensson at gmail dot com
2006-06-04 18:19 ` mmitchel at gcc dot gnu dot org
2006-06-26 23:41 ` laurent at guerby dot net
2006-06-27  3:05 ` kenner at vlsi1 dot ultra dot nyu dot edu
2006-10-29 23:17 ` [Bug ada/26797] [4.2/4.3 regression] " ebotcazou at gcc dot gnu dot org
2006-10-30  9:04 ` law at redhat dot com
2006-10-30  9:21 ` ebotcazou at gcc dot gnu dot org
2007-03-04 10:06 ` ebotcazou at gcc dot gnu dot org
2007-03-04 10:08 ` [Bug ada/26797] [4.3 regression] ACATS " ebotcazou at gcc dot gnu dot org
2007-03-08  9:57 ` [Bug ada/26797] [4.3 regression] ACATS cxh1001 fails baldrick at gcc dot gnu dot org
2007-03-08 12:54 ` kenner at vlsi1 dot ultra dot nyu dot edu
2007-03-08 16:06 ` baldrick at free dot fr
2007-03-08 16:52 ` kenner at vlsi1 dot ultra dot nyu dot edu
2007-03-09 10:41 ` baldrick at free dot fr [this message]
2007-03-09 11:11 ` rguenth at gcc dot gnu dot org
2007-03-09 11:19 ` ebotcazou at gcc dot gnu dot org
2007-03-09 11:35 ` baldrick at free dot fr
2007-03-09 11:50 ` baldrick at free dot fr
2007-03-09 13:59 ` kenner at vlsi1 dot ultra dot nyu dot edu
2007-03-09 14:19 ` kenner at vlsi1 dot ultra dot nyu dot edu
2007-03-09 14:29 ` kenner at vlsi1 dot ultra dot nyu dot edu
2007-03-09 22:44 ` baldrick at free dot fr
2007-03-09 23:10 ` baldrick at free dot fr
2007-03-09 23:13 ` kenner at vlsi1 dot ultra dot nyu dot edu
2007-03-09 23:41 ` baldrick at free dot fr
2007-03-10  0:17 ` kenner at vlsi1 dot ultra dot nyu dot edu
2007-03-10 16:52 ` ebotcazou at gcc dot gnu dot org
2007-03-13 10:30 ` baldrick at free dot fr
2007-03-13 12:34 ` kenner at vlsi1 dot ultra dot nyu dot edu
2007-09-12 15:53 ` ebotcazou at gcc dot gnu dot org
2007-09-12 15:55 ` ebotcazou at gcc dot gnu dot org
2007-09-15  6:35 ` law at redhat dot com

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=20070309104118.22864.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).