public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/43940]  New: DOM doesn't propagate constants properly
@ 2010-04-29 14:57 rguenth at gcc dot gnu dot org
  2010-07-24 21:45 ` [Bug tree-optimization/43940] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-29 14:57 UTC (permalink / raw)
  To: gcc-bugs

For

int main()
{
  void *p = __builtin_malloc (4);
  if (p)
    {
      __builtin_free (p);
      p = 0;
    }
  __builtin_free (p);
  return 0;
}

DOM does not propagate p == 0 on the else path leaving

<bb 2>:
  p_2 = __builtin_malloc (4);
  if (p_2 != 0B)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 3>:
  __builtin_free (p_2);

<bb 4>:
  # p_1 = PHI <p_2(2), 0B(3)>
  __builtin_free (p_1);


VRP can do this.


-- 
           Summary: DOM doesn't propagate constants properly
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


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


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

* [Bug tree-optimization/43940] DOM doesn't propagate constants properly
  2010-04-29 14:57 [Bug tree-optimization/43940] New: DOM doesn't propagate constants properly rguenth at gcc dot gnu dot org
@ 2010-07-24 21:45 ` pinskia at gcc dot gnu dot org
  2010-07-24 22:05 ` steven at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-07-24 21:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2010-07-24 21:44 -------
Confirmed.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-07-24 21:44:54
               date|                            |


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


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

* [Bug tree-optimization/43940] DOM doesn't propagate constants properly
  2010-04-29 14:57 [Bug tree-optimization/43940] New: DOM doesn't propagate constants properly rguenth at gcc dot gnu dot org
  2010-07-24 21:45 ` [Bug tree-optimization/43940] " pinskia at gcc dot gnu dot org
@ 2010-07-24 22:05 ` steven at gcc dot gnu dot org
  2010-07-25 10:29 ` steven at gcc dot gnu dot org
  2010-07-25 16:25 ` steven at gcc dot gnu dot org
  3 siblings, 0 replies; 8+ messages in thread
From: steven at gcc dot gnu dot org @ 2010-07-24 22:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from steven at gcc dot gnu dot org  2010-07-24 22:04 -------
Investigating...


-- 

steven at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |steven at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2010-07-24 21:44:54         |2010-07-24 22:04:50
               date|                            |


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


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

* [Bug tree-optimization/43940] DOM doesn't propagate constants properly
  2010-04-29 14:57 [Bug tree-optimization/43940] New: DOM doesn't propagate constants properly rguenth at gcc dot gnu dot org
  2010-07-24 21:45 ` [Bug tree-optimization/43940] " pinskia at gcc dot gnu dot org
  2010-07-24 22:05 ` steven at gcc dot gnu dot org
@ 2010-07-25 10:29 ` steven at gcc dot gnu dot org
  2010-07-25 16:25 ` steven at gcc dot gnu dot org
  3 siblings, 0 replies; 8+ messages in thread
From: steven at gcc dot gnu dot org @ 2010-07-25 10:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from steven at gcc dot gnu dot org  2010-07-25 10:29 -------
VRP does this with ASSERT_EXPRs.  DOM does not optimize this because bb4 has
two predecessors, and record_equivalences_from_incoming_edge only records from
a single predecessor.

This should probably be handled record_equivalences_from_phis by looking at the
value of the incoming argument, before calling operand_equal_for_phi_arg_p.


-- 


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


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

* [Bug tree-optimization/43940] DOM doesn't propagate constants properly
  2010-04-29 14:57 [Bug tree-optimization/43940] New: DOM doesn't propagate constants properly rguenth at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2010-07-25 10:29 ` steven at gcc dot gnu dot org
@ 2010-07-25 16:25 ` steven at gcc dot gnu dot org
  3 siblings, 0 replies; 8+ messages in thread
From: steven at gcc dot gnu dot org @ 2010-07-25 16:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from steven at gcc dot gnu dot org  2010-07-25 16:25 -------
cprop_into_successor_phis only propagates SSA_NAME_VALUEs, but not conditional
copies/constants. May be a better place to fix this bug.


-- 


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


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

* [Bug tree-optimization/43940] DOM doesn't propagate constants properly
       [not found] <bug-43940-4@http.gcc.gnu.org/bugzilla/>
  2012-03-18 23:08 ` steven at gcc dot gnu.org
  2012-03-19  9:45 ` rguenth at gcc dot gnu.org
@ 2012-03-19  9:55 ` stevenb.gcc at gmail dot com
  2 siblings, 0 replies; 8+ messages in thread
From: stevenb.gcc at gmail dot com @ 2012-03-19  9:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from stevenb.gcc at gmail dot com <stevenb.gcc at gmail dot com> 2012-03-19 09:51:41 UTC ---
> --- Comment #6 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-19 09:34:58 UTC ---
> I think this was fixed by
>
> 2012-02-29  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
>
>        PR tree-optimization/52424
>        * tree-ssa-dom.c (dom_opt_leave_block): Push a marker before
>        calling dom_thread_across_edge.

I think it was fixed by ifcombine. But in any case, yes, resolved AFAIC.


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

* [Bug tree-optimization/43940] DOM doesn't propagate constants properly
       [not found] <bug-43940-4@http.gcc.gnu.org/bugzilla/>
  2012-03-18 23:08 ` steven at gcc dot gnu.org
@ 2012-03-19  9:45 ` rguenth at gcc dot gnu.org
  2012-03-19  9:55 ` stevenb.gcc at gmail dot com
  2 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-03-19  9:45 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Depends on|                            |52424
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #6 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-19 09:34:58 UTC ---
I think this was fixed by

2012-02-29  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

        PR tree-optimization/52424
        * tree-ssa-dom.c (dom_opt_leave_block): Push a marker before
        calling dom_thread_across_edge.


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

* [Bug tree-optimization/43940] DOM doesn't propagate constants properly
       [not found] <bug-43940-4@http.gcc.gnu.org/bugzilla/>
@ 2012-03-18 23:08 ` steven at gcc dot gnu.org
  2012-03-19  9:45 ` rguenth at gcc dot gnu.org
  2012-03-19  9:55 ` stevenb.gcc at gmail dot com
  2 siblings, 0 replies; 8+ messages in thread
From: steven at gcc dot gnu.org @ 2012-03-18 23:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Steven Bosscher <steven at gcc dot gnu.org> 2012-03-18 22:48:49 UTC ---
With trunk today (r185508), on x86_64-linux at -O2 -fno-tree-vrp:

The .072t.ifcombine dump:
main ()
{
  void * p;

<bb 2>:
  p_2 = __builtin_malloc (4);
  if (p_2 != 0B)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 3>:
  __builtin_free (p_2);

<bb 4>:
  # p_1 = PHI <p_2(2), 0B(3)>
  __builtin_free (p_1);
  return 0;

}


And the .073t.phiopt1 dump:
main ()
{
  void * p;

<bb 2>:
  p_2 = __builtin_malloc (4);
  if (p_2 != 0B)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 3>:
  __builtin_free (p_2);

<bb 4>:
  # p_1 = PHI <0B(2), 0B(3)>
  __builtin_free (p_1);
  return 0;

}


And finally the 080t.dom1 dump:
main ()
{
  void * p;

<bb 2>:
  p_2 = __builtin_malloc (4);
  if (p_2 != 0B)
    goto <bb 3>; 
  else
    goto <bb 4>;

<bb 3>:
  __builtin_free (p_2);

<bb 4>:
  # p_1 = PHI <0B(2), 0B(3)>
  GIMPLE_NOP
  return 0;

}


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

end of thread, other threads:[~2012-03-19  9:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-29 14:57 [Bug tree-optimization/43940] New: DOM doesn't propagate constants properly rguenth at gcc dot gnu dot org
2010-07-24 21:45 ` [Bug tree-optimization/43940] " pinskia at gcc dot gnu dot org
2010-07-24 22:05 ` steven at gcc dot gnu dot org
2010-07-25 10:29 ` steven at gcc dot gnu dot org
2010-07-25 16:25 ` steven at gcc dot gnu dot org
     [not found] <bug-43940-4@http.gcc.gnu.org/bugzilla/>
2012-03-18 23:08 ` steven at gcc dot gnu.org
2012-03-19  9:45 ` rguenth at gcc dot gnu.org
2012-03-19  9:55 ` stevenb.gcc at gmail dot com

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