public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/19938] New: Missed jump threading opportunity due to signedness difference
@ 2005-02-14  0:19 kazu at cs dot umass dot edu
  2005-02-14  0:26 ` [Bug tree-optimization/19938] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: kazu at cs dot umass dot edu @ 2005-02-14  0:19 UTC (permalink / raw)
  To: gcc-bugs

Consider:

void
foo (int length, int *array)
{
  int i;

  for (i = 0; i < length; i++)
    {
      if (array[i] != 0)
	{
	  int j;

	  for (j = 0; j < length; j++)
	    ;

	  if (j != length)
	    array[i] = 0;
	}
    }
}

A part of the last tree SSA form looks like so:

<L2>:;
  j_16 = j_15 + 1;
  D.1187_17 = (unsigned int) length_4;
  if (j_16 != D.1187_17) goto <L2>; else goto <L4>;

<L4>:;
  if (length_4 != j_16) goto <L5>; else goto <L6>;

Note that when we take edge from <L2> to <L4>, we know that we leave <L4>
for <L6> because length_4 == D.1187_17 == j_16, but we don't notice that
because a sign-changing cast is in the way.

CSE pickes up this optimization oportunity.

Reduced from reload.c:find_reloads.

-- 
           Summary: Missed jump threading opportunity due to signedness
                    difference
           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
OtherBugsDependingO 19721,19794
             nThis:


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


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

* [Bug tree-optimization/19938] Missed jump threading opportunity due to signedness difference
  2005-02-14  0:19 [Bug tree-optimization/19938] New: Missed jump threading opportunity due to signedness difference kazu at cs dot umass dot edu
@ 2005-02-14  0:26 ` pinskia at gcc dot gnu dot org
  2005-02-14 10:39 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-14  0:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-13 18:04 -------
Confirmed, but note the following in the tree level is really invalid:
  D.1187_17 = (unsigned int) length_4;
  if (j_16 != D.1187_17) goto <L2>; else goto <L4>;

as j_16 is signed and we are comparing against an unsigned type.

In which case this is an IV-OPT problem, very closely related to PR 19937 (which by the way is a wrong-
code regression).

If someone would add more checking we would have caught this earlier.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |19937
           Severity|enhancement                 |normal
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-02-13 18:04:35
               date|                            |


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


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

* [Bug tree-optimization/19938] Missed jump threading opportunity due to signedness difference
  2005-02-14  0:19 [Bug tree-optimization/19938] New: Missed jump threading opportunity due to signedness difference kazu at cs dot umass dot edu
  2005-02-14  0:26 ` [Bug tree-optimization/19938] " pinskia at gcc dot gnu dot org
@ 2005-02-14 10:39 ` pinskia at gcc dot gnu dot org
  2005-02-25 16:58 ` rakdver at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-14 10:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-13 23:03 -------
In fact I just tested the patch for PR 19937 and it fixes this bug also.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unknown                     |4.0.0


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


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

* [Bug tree-optimization/19938] Missed jump threading opportunity due to signedness difference
  2005-02-14  0:19 [Bug tree-optimization/19938] New: Missed jump threading opportunity due to signedness difference kazu at cs dot umass dot edu
  2005-02-14  0:26 ` [Bug tree-optimization/19938] " pinskia at gcc dot gnu dot org
  2005-02-14 10:39 ` pinskia at gcc dot gnu dot org
@ 2005-02-25 16:58 ` rakdver at gcc dot gnu dot org
  2005-02-25 17:01 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rakdver at gcc dot gnu dot org @ 2005-02-25 16:58 UTC (permalink / raw)
  To: gcc-bugs



-- 
Bug 19938 depends on bug 19937, which changed state.

Bug 19937 Summary: [4.0 regression] Wrong loop exit (causes binutils to fail)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19937

           What    |Old Value                   |New Value
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

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


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

* [Bug tree-optimization/19938] Missed jump threading opportunity due to signedness difference
  2005-02-14  0:19 [Bug tree-optimization/19938] New: Missed jump threading opportunity due to signedness difference kazu at cs dot umass dot edu
                   ` (2 preceding siblings ...)
  2005-02-25 16:58 ` rakdver at gcc dot gnu dot org
@ 2005-02-25 17:01 ` pinskia at gcc dot gnu dot org
  2005-02-25 22:29 ` kazu at cs dot umass dot edu
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-25 17:01 UTC (permalink / raw)
  To: gcc-bugs



-- 
Bug 19938 depends on bug 19937, which changed state.

Bug 19937 Summary: [4.0 regression] Wrong loop exit (causes binutils to fail)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19937

           What    |Old Value                   |New Value
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |

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


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

* [Bug tree-optimization/19938] Missed jump threading opportunity due to signedness difference
  2005-02-14  0:19 [Bug tree-optimization/19938] New: Missed jump threading opportunity due to signedness difference kazu at cs dot umass dot edu
                   ` (3 preceding siblings ...)
  2005-02-25 17:01 ` pinskia at gcc dot gnu dot org
@ 2005-02-25 22:29 ` kazu at cs dot umass dot edu
  2005-02-26  0:44 ` rakdver at gcc dot gnu dot org
  2005-02-26  0:55 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: kazu at cs dot umass dot edu @ 2005-02-25 22:29 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2005-02-25 16:29 -------
Yes, this is fixed.

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


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


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

* [Bug tree-optimization/19938] Missed jump threading opportunity due to signedness difference
  2005-02-14  0:19 [Bug tree-optimization/19938] New: Missed jump threading opportunity due to signedness difference kazu at cs dot umass dot edu
                   ` (4 preceding siblings ...)
  2005-02-25 22:29 ` kazu at cs dot umass dot edu
@ 2005-02-26  0:44 ` rakdver at gcc dot gnu dot org
  2005-02-26  0:55 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: rakdver at gcc dot gnu dot org @ 2005-02-26  0:44 UTC (permalink / raw)
  To: gcc-bugs



-- 
Bug 19938 depends on bug 19937, which changed state.

Bug 19937 Summary: [4.0 regression] Wrong loop exit (causes binutils to fail)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19937

           What    |Old Value                   |New Value
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

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


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

* [Bug tree-optimization/19938] Missed jump threading opportunity due to signedness difference
  2005-02-14  0:19 [Bug tree-optimization/19938] New: Missed jump threading opportunity due to signedness difference kazu at cs dot umass dot edu
                   ` (5 preceding siblings ...)
  2005-02-26  0:44 ` rakdver at gcc dot gnu dot org
@ 2005-02-26  0:55 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-26  0:55 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-25 18:38 -------
And in 4.0 also.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.0


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


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

end of thread, other threads:[~2005-02-25 18:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-14  0:19 [Bug tree-optimization/19938] New: Missed jump threading opportunity due to signedness difference kazu at cs dot umass dot edu
2005-02-14  0:26 ` [Bug tree-optimization/19938] " pinskia at gcc dot gnu dot org
2005-02-14 10:39 ` pinskia at gcc dot gnu dot org
2005-02-25 16:58 ` rakdver at gcc dot gnu dot org
2005-02-25 17:01 ` pinskia at gcc dot gnu dot org
2005-02-25 22:29 ` kazu at cs dot umass dot edu
2005-02-26  0:44 ` rakdver at gcc dot gnu dot org
2005-02-26  0:55 ` 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).