public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/19098] New: tree-ssa-dom.c has an "if" statement whose condition is probably wrong
@ 2004-12-21  5:59 kazu at cs dot umass dot edu
  2004-12-21  6:51 ` [Bug tree-optimization/19098] " bangerth at dealii dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-12-21  5:59 UTC (permalink / raw)
  To: gcc-bugs

tree-ssa-dom.c has the following

      if (!e->flags & EDGE_DFS_BACK)

which is always 0 because !e->flags is always 0 or 1, and
EDGE_DFS_BACK is 32.

-- 
           Summary: tree-ssa-dom.c has an "if" statement whose condition is
                    probably wrong
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          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,law at redhat dot com


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


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

* [Bug tree-optimization/19098] tree-ssa-dom.c has an "if" statement whose condition is probably wrong
  2004-12-21  5:59 [Bug tree-optimization/19098] New: tree-ssa-dom.c has an "if" statement whose condition is probably wrong kazu at cs dot umass dot edu
@ 2004-12-21  6:51 ` bangerth at dealii dot org
  2004-12-21  7:34 ` law at redhat dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: bangerth at dealii dot org @ 2004-12-21  6:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-12-21 06:51 -------
Confirmed. This is in line 697 of version 1.20 of that file. This 
should definitely be resolved before 4.0 goes out. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |critical
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-12-21 06:51:38
               date|                            |
   Target Milestone|---                         |4.0.0


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


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

* [Bug tree-optimization/19098] tree-ssa-dom.c has an "if" statement whose condition is probably wrong
  2004-12-21  5:59 [Bug tree-optimization/19098] New: tree-ssa-dom.c has an "if" statement whose condition is probably wrong kazu at cs dot umass dot edu
  2004-12-21  6:51 ` [Bug tree-optimization/19098] " bangerth at dealii dot org
@ 2004-12-21  7:34 ` law at redhat dot com
  2004-12-21  8:07 ` kazu at cs dot umass dot edu
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: law at redhat dot com @ 2004-12-21  7:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From law at redhat dot com  2004-12-21 07:34 -------
Subject: Re:  New: tree-ssa-dom.c has an "if"
	statement whose condition is probably wrong

On Tue, 2004-12-21 at 05:59 +0000, kazu at cs dot umass dot edu wrote:
> tree-ssa-dom.c has the following
> 
>       if (!e->flags & EDGE_DFS_BACK)
> 
> which is always 0 because !e->flags is always 0 or 1, and
> EDGE_DFS_BACK is 32.
That should be

!(e->flags & EDGE_DFS_BACK)


FWIW, this bug shouldn't affect correctness in any way -- it's merely
avoiding a pessimization.

jef




-- 


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


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

* [Bug tree-optimization/19098] tree-ssa-dom.c has an "if" statement whose condition is probably wrong
  2004-12-21  5:59 [Bug tree-optimization/19098] New: tree-ssa-dom.c has an "if" statement whose condition is probably wrong kazu at cs dot umass dot edu
  2004-12-21  6:51 ` [Bug tree-optimization/19098] " bangerth at dealii dot org
  2004-12-21  7:34 ` law at redhat dot com
@ 2004-12-21  8:07 ` kazu at cs dot umass dot edu
  2004-12-21 15:26 ` law at redhat dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-12-21  8:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2004-12-21 08:07 -------
Can we do something like the following?

Avoid creating multiple entries to into a loop before the loop optimizations run.
Try to thread every edge after the loop optimizations run.

The loop optimizers probably don't like irreducible loops,
but I guess the real CPU doesn't care about them, and
if we can skip some conditional jumps, that might be good.

I don't know if this idea is any good, but just a thought.


-- 


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


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

* [Bug tree-optimization/19098] tree-ssa-dom.c has an "if" statement whose condition is probably wrong
  2004-12-21  5:59 [Bug tree-optimization/19098] New: tree-ssa-dom.c has an "if" statement whose condition is probably wrong kazu at cs dot umass dot edu
                   ` (2 preceding siblings ...)
  2004-12-21  8:07 ` kazu at cs dot umass dot edu
@ 2004-12-21 15:26 ` law at redhat dot com
  2004-12-23 18:30 ` law at redhat dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: law at redhat dot com @ 2004-12-21 15:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From law at redhat dot com  2004-12-21 15:26 -------
Subject: Re:  tree-ssa-dom.c has an "if"
	statement whose condition is probably wrong

On Tue, 2004-12-21 at 08:07 +0000, kazu at cs dot umass dot edu wrote:
> ------- Additional Comments From kazu at cs dot umass dot edu  2004-12-21 08:07 -------
> Can we do something like the following?
> 
> Avoid creating multiple entries to into a loop before the loop optimizations run.
> Try to thread every edge after the loop optimizations run.
Possibly.  I don't know if it's worth the headache and cost though.

Jeff



-- 


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


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

* [Bug tree-optimization/19098] tree-ssa-dom.c has an "if" statement whose condition is probably wrong
  2004-12-21  5:59 [Bug tree-optimization/19098] New: tree-ssa-dom.c has an "if" statement whose condition is probably wrong kazu at cs dot umass dot edu
                   ` (3 preceding siblings ...)
  2004-12-21 15:26 ` law at redhat dot com
@ 2004-12-23 18:30 ` law at redhat dot com
  2005-01-18 10:49 ` jakub at gcc dot gnu dot org
  2005-01-18 14:09 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: law at redhat dot com @ 2004-12-23 18:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From law at redhat dot com  2004-12-23 18:29 -------
Subject: Re:  New: tree-ssa-dom.c has an "if"
	statement whose condition is probably wrong

On Tue, 2004-12-21 at 05:59 +0000, kazu at cs dot umass dot edu wrote:
> tree-ssa-dom.c has the following
> 
>       if (!e->flags & EDGE_DFS_BACK)
> 
> which is always 0 because !e->flags is always 0 or 1, and
> EDGE_DFS_BACK is 32.
As it turns out simply changing it to

if (!(e->flags & EDFS_DFS_BACK))

will introduce regressions.  Why?  Because we fail to thread jumps
in some cases which causes us to give bogus uninitialized variable
warnings in code like this:


  if (cond)  
    var = whatever

  while (cond)
    use var


The fundamental problem this code is trying to avoid is creating jumps
into the middle of a loop (which would create an irreducible region).

However, I _think_ there are cases where we can allow the jump to be
threaded.  ie, there are cases where threading the jump is just going
to rotate the loop rather than creating a jump into the loop body.

ie, in the case above threading the jump would effectively create

if (cond)
  {
    do {
      use var
    } while (cond)
  }


So the question becomes can we identify those cases where jump threading
across a loop header is simply going to rotate the loop and if we only
thread those cases do we avoid the bogus uninitialized variable
warnings.

I think the answer is we can do a trivial test to catch the majority of
cases we care about.  Given an edge E where E->dest is a loop header and
E is not a backedge, we can safely thread through E->dest if E is the
only incoming edge into E->dest which is not marked with EDGE_DFS_BACK.

ie, E represents the only edge which enters the loop.  If we redirect
that edge to a point inside the loop, then all we have done is change
the loop entry point.

This could be extended to handle cases where we're threading all
incoming non-loop edges to the same block within the loop, but I don't
see a need to do that right now.  That would require significantly
more work in tree-ssa-threadupdate and tree-ssa-dom.

Jeff





-- 


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


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

* [Bug tree-optimization/19098] tree-ssa-dom.c has an "if" statement whose condition is probably wrong
  2004-12-21  5:59 [Bug tree-optimization/19098] New: tree-ssa-dom.c has an "if" statement whose condition is probably wrong kazu at cs dot umass dot edu
                   ` (4 preceding siblings ...)
  2004-12-23 18:30 ` law at redhat dot com
@ 2005-01-18 10:49 ` jakub at gcc dot gnu dot org
  2005-01-18 14:09 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2005-01-18 10:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jakub at gcc dot gnu dot org  2005-01-18 10:49 -------
The patch has been committed, can this be closed?

-- 


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


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

* [Bug tree-optimization/19098] tree-ssa-dom.c has an "if" statement whose condition is probably wrong
  2004-12-21  5:59 [Bug tree-optimization/19098] New: tree-ssa-dom.c has an "if" statement whose condition is probably wrong kazu at cs dot umass dot edu
                   ` (5 preceding siblings ...)
  2005-01-18 10:49 ` jakub at gcc dot gnu dot org
@ 2005-01-18 14:09 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-18 14:09 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-18 14:08 -------
Fixed.

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


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


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

end of thread, other threads:[~2005-01-18 14:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-21  5:59 [Bug tree-optimization/19098] New: tree-ssa-dom.c has an "if" statement whose condition is probably wrong kazu at cs dot umass dot edu
2004-12-21  6:51 ` [Bug tree-optimization/19098] " bangerth at dealii dot org
2004-12-21  7:34 ` law at redhat dot com
2004-12-21  8:07 ` kazu at cs dot umass dot edu
2004-12-21 15:26 ` law at redhat dot com
2004-12-23 18:30 ` law at redhat dot com
2005-01-18 10:49 ` jakub at gcc dot gnu dot org
2005-01-18 14:09 ` 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).