public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/19788] New: Inconsistent handling of -1.
@ 2005-02-06 10:20 kazu@cs.umass.edu
  2005-02-06 15:29 ` [Bug tree-optimization/19788] " kazu@cs.umass.edu
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: kazu@cs.umass.edu @ 2005-02-06 10:20 UTC (permalink / raw)
  To: gcc-bugs

Consider:

int
foo (void)
{
  return -1;
}

int
bar (void)
{
  unsigned int a = 0xffffffff;
  return a;
}

int
baz (void)
{
  int a = -1;
  unsigned int b = 0xffffffff;
  return a == (int) b;
}

Here is what I get:

;; Function foo (foo)

foo ()
{
<bb 0>:
  return -1;

}

;; Function bar (bar)

bar ()
{
  int D.1124;

<bb 0>:
  D.1124 = -000000001;
  return D.1124;

}

;; Function baz (baz)

baz ()
{
  int b.0;

<bb 0>:
  b.0 = -000000001;
  return b.0 == -1;

}

Note that -1 is represented in two different ways in foo and bar.
Worse yet, the tree optimizers do not know that they are equal in baz.
baz is optimized as expected at RTL level.

-- 
           Summary: Inconsistent handling of -1.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: missed-optimization, TREE
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kazu at cs dot umass dot edu
                CC: gcc-bugs at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/19788] Inconsistent handling of -1.
  2005-02-06 10:20 [Bug tree-optimization/19788] New: Inconsistent handling of -1 kazu@cs.umass.edu
@ 2005-02-06 15:29 ` kazu@cs.umass.edu
  2005-02-06 16:05 ` pinskia@gcc.gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: kazu@cs.umass.edu @ 2005-02-06 15:29 UTC (permalink / raw)
  To: gcc-bugs

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |19721
              nThis|                            |


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/19788] Inconsistent handling of -1.
  2005-02-06 10:20 [Bug tree-optimization/19788] New: Inconsistent handling of -1 kazu@cs.umass.edu
  2005-02-06 15:29 ` [Bug tree-optimization/19788] " kazu@cs.umass.edu
@ 2005-02-06 16:05 ` pinskia@gcc.gnu.org
  2005-02-06 16:54 ` schlie@comcast.net
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia@gcc.gnu.org @ 2005-02-06 16:05 UTC (permalink / raw)
  To: gcc-bugs

------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-06 16:04 -------
Confirmed.  The problem is from TREE_OVERFLOW/TREE_CONSTANT_OVERFLOW.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-02-06 16:04:44
               date|                            |


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/19788] Inconsistent handling of -1.
  2005-02-06 10:20 [Bug tree-optimization/19788] New: Inconsistent handling of -1 kazu@cs.umass.edu
  2005-02-06 15:29 ` [Bug tree-optimization/19788] " kazu@cs.umass.edu
  2005-02-06 16:05 ` pinskia@gcc.gnu.org
@ 2005-02-06 16:54 ` schlie@comcast.net
  2005-02-06 16:54 ` pinskia@gcc.gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: schlie@comcast.net @ 2005-02-06 16:54 UTC (permalink / raw)
  To: gcc-bugs

------- Additional Comments From schlie at comcast dot net  2005-02-06 17:14 -------
(In reply to comment #1)

- as I'm curious as to what the "proper" interpretation/handling of
  target dependant constant value casts should be; it seems that in
  the provided example, the optimized transformations of 0xffffffff
  to an (int)-1 intermediate value in bar & baz are consistent, assuming:

  (((0xffffffff) >> ((sizeof(int) * BITS_PER_UNIT)) & 1)

  however would have expected the comparison between a & b in baz
  to have been optimized away; is this a reasonable expectation?


-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/19788] Inconsistent handling of -1.
  2005-02-06 10:20 [Bug tree-optimization/19788] New: Inconsistent handling of -1 kazu@cs.umass.edu
                   ` (2 preceding siblings ...)
  2005-02-06 16:54 ` schlie@comcast.net
@ 2005-02-06 16:54 ` pinskia@gcc.gnu.org
  2005-02-08  5:46 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia@gcc.gnu.org @ 2005-02-06 16:54 UTC (permalink / raw)
  To: gcc-bugs

------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-06 17:17 -------
(In reply to comment #2)
> (In reply to comment #1)
Really TREE_OVERFLOW/TREE_CONSTANT_OVERFLOW should go away, there has been some talk about 
removing them.  on the tree level, having that flag set we really say the constant is no longer be able to 
prograte which causes the real problem.

-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/19788] Inconsistent handling of -1.
  2005-02-06 10:20 [Bug tree-optimization/19788] New: Inconsistent handling of -1 kazu@cs.umass.edu
                   ` (3 preceding siblings ...)
  2005-02-06 16:54 ` pinskia@gcc.gnu.org
@ 2005-02-08  5:46 ` pinskia at gcc dot gnu dot org
  2005-03-16 12:31 ` steven at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-08  5:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-07 20:17 -------
(In reply to comment #3)
> (In reply to comment #2)
> > (In reply to comment #1)
> Really TREE_OVERFLOW/TREE_CONSTANT_OVERFLOW should go away, there has been some talk 
about 
> removing them.  on the tree level, having that flag set we really say the constant is no longer be able 
to 
> prograte which causes the real problem.

Note I am talking about:
http://www.srcf.ucam.org/~jsm28/gcc/

"Similarly, it should also be possible to get rid of at least one of TREE_OVERFLOW and 
TREE_CONSTANT_OVERFLOW, which also describe what are essentially front-end properties."

-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/19788] Inconsistent handling of -1.
  2005-02-06 10:20 [Bug tree-optimization/19788] New: Inconsistent handling of -1 kazu@cs.umass.edu
                   ` (4 preceding siblings ...)
  2005-02-08  5:46 ` pinskia at gcc dot gnu dot org
@ 2005-03-16 12:31 ` steven at gcc dot gnu dot org
  2005-03-16 14:53 ` kazu at cs dot umass dot edu
  2005-03-16 14:54 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-03-16 12:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2005-03-16 12:30 -------
Someone should check if this is fixed now, by this patch:
http://gcc.gnu.org/ml/gcc-patches/2005-03/msg01122.html

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |stevenb at suse dot de
             Status|NEW                         |WAITING


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/19788] Inconsistent handling of -1.
  2005-02-06 10:20 [Bug tree-optimization/19788] New: Inconsistent handling of -1 kazu@cs.umass.edu
                   ` (5 preceding siblings ...)
  2005-03-16 12:31 ` steven at gcc dot gnu dot org
@ 2005-03-16 14:53 ` kazu at cs dot umass dot edu
  2005-03-16 14:54 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: kazu at cs dot umass dot edu @ 2005-03-16 14:53 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2005-03-16 14:53 -------
Here is what I get from the current mainline.

;; Function foo (foo)

foo ()
{
  int D.1132;

<bb 0>:
  return -1;

}



;; Function bar (bar)

bar ()
{
  unsigned int a;
  int D.1137;

<bb 0>:
  return -000000001;

}



;; Function baz (baz)

baz ()
{
  unsigned int b;
  int a;
  int b.0;
  int D.1143;

<bb 0>:
  return 1;

}

So the problem seems to be fixed.
It would still be nice to see -1 instead of -000000001 though.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/19788] Inconsistent handling of -1.
  2005-02-06 10:20 [Bug tree-optimization/19788] New: Inconsistent handling of -1 kazu@cs.umass.edu
                   ` (6 preceding siblings ...)
  2005-03-16 14:53 ` kazu at cs dot umass dot edu
@ 2005-03-16 14:54 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-16 14:54 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.1.0


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-03-16 14:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-06 10:20 [Bug tree-optimization/19788] New: Inconsistent handling of -1 kazu@cs.umass.edu
2005-02-06 15:29 ` [Bug tree-optimization/19788] " kazu@cs.umass.edu
2005-02-06 16:05 ` pinskia@gcc.gnu.org
2005-02-06 16:54 ` schlie@comcast.net
2005-02-06 16:54 ` pinskia@gcc.gnu.org
2005-02-08  5:46 ` pinskia at gcc dot gnu dot org
2005-03-16 12:31 ` steven at gcc dot gnu dot org
2005-03-16 14:53 ` kazu at cs dot umass dot edu
2005-03-16 14:54 ` pinskia at gcc dot gnu dot org

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).