public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/51964] New: Missed tail merging opportunity
@ 2012-01-23 13:45 vries at gcc dot gnu.org
  2012-01-23 13:51 ` [Bug tree-optimization/51964] " vries at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2012-01-23 13:45 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51964
           Summary: Missed tail merging opportunity
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: vries@gcc.gnu.org


pr51879-5.c:
...
int bar (int);
void baz (int);
void foo2 (void);
void
foo (int y, int z)
{
  int a;
  if (y == 6)
    {
      if (z)
    foo2 ();
      a = bar (7);
    }
  else
    a = bar (7);
  baz (a);
}
...

compile:
...
gcc -O2 pr51879-5.c -S -fdump-tree-all-all
...

pr51879-5.c.094t.pre:
...
  # BLOCK 5 freq:4877
  # PRED: 8 [100.0%]  (fallthru) 4 [100.0%]  (fallthru,exec)
  # .MEMD.1719_6 = PHI <.MEMD.1719_8(D)(8), .MEMD.1719_9(4)>
  # .MEMD.1719_10 = VDEF <.MEMD.1719_6>
  # USE = nonlocal 
  # CLB = nonlocal 
  aD.1712_4 = barD.1703 (7);
  goto <bb 7>;
  # SUCC: 7 [100.0%]  (fallthru,exec)

  # BLOCK 6 freq:5123
  # PRED: 2 [51.2%]  (false,exec)
  # .MEMD.1719_11 = VDEF <.MEMD.1719_8(D)>
  # USE = nonlocal 
  # CLB = nonlocal 
  aD.1712_5 = barD.1703 (7);
  # SUCC: 7 [100.0%]  (fallthru,exec)

  # BLOCK 7 freq:10000
  # PRED: 5 [100.0%]  (fallthru,exec) 6 [100.0%]  (fallthru,exec)
  # aD.1712_1 = PHI <aD.1712_4(5), aD.1712_5(6)>
  # .MEMD.1719_7 = PHI <.MEMD.1719_10(5), .MEMD.1719_11(6)>
  # .MEMD.1719_12 = VDEF <.MEMD.1719_7>
  # USE = nonlocal 
  # CLB = nonlocal 
  bazD.1705 (aD.1712_1);
  # VUSE <.MEMD.1719_12>
  return;
  # SUCC: EXIT [100.0%] 
...

Blocks 5 and 6 are not merged by tail_merge_optimize (they are merged by rtl
cross-jumping though).

The reason the blocks are not merged by tail_merge_optimize is that
tail_merge_optimize uses value numbering to determine equivalence of blocks.
And since the calls have a different vuse (.MEMD.1719_6 and .MEMD.1719_8(D))
the results of the calls won't have the same value number (even after fixing
PR51879).

However, the reason we can merge the calls is not because the calls have the
same result. It's because the results are used in the same way. To detect this
we should use a different comparison mechanism than the current.


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

end of thread, other threads:[~2023-05-08  7:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-23 13:45 [Bug tree-optimization/51964] New: Missed tail merging opportunity vries at gcc dot gnu.org
2012-01-23 13:51 ` [Bug tree-optimization/51964] " vries at gcc dot gnu.org
2021-12-28  6:52 ` pinskia at gcc dot gnu.org
2021-12-28  6:56 ` pinskia at gcc dot gnu.org
2021-12-28  6:59 ` pinskia at gcc dot gnu.org
2023-05-06 21:29 ` pinskia at gcc dot gnu.org
2023-05-08  7:41 ` pinskia at gcc dot gnu.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).