diff mbox

Add missing profile updates to jump threading code

Message ID CAAe5K+Xb6cPZnsXXYdNS2U-sjJOhCt5SU0T0JM3qTm7zcsbXdQ@mail.gmail.com
State New
Headers show

Commit Message

Teresa Johnson Sept. 30, 2013, 6:52 p.m. UTC
The jump threading handling in the case of a joiner block was not updating
profile information (it was being updated in the non-joiner case). Added
profile updates for the joiner case, in one place by commoning the
handling between the joiner and non-joiner cases.

Bootstrapped and tested on x86_64-unknown-linux-gnu. Ok for trunk?

Thanks,
Teresa

2013-09-30  Teresa Johnson  <tejohnson@google.com>

        * tree-ssa-threadupdate.c (ssa_fix_duplicate_block_edges):
        Update redirected out edge count in joiner case.
        (ssa_redirect_edges): Common the joiner and non-joiner cases
        so that joiner case gets profile updates.

        * testsuite/gcc.dg/tree-ssa/ssa-dom-thread-3.c (expand_one_var):
        Update for additional dump message.

 /* { dg-final { cleanup-tree-dump "dom1" } } */

Comments

Jeff Law Sept. 30, 2013, 7:07 p.m. UTC | #1
On 09/30/13 12:52, Teresa Johnson wrote:
> The jump threading handling in the case of a joiner block was not updating
> profile information (it was being updated in the non-joiner case). Added
> profile updates for the joiner case, in one place by commoning the
> handling between the joiner and non-joiner cases.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu. Ok for trunk?
>
> Thanks,
> Teresa
>
> 2013-09-30  Teresa Johnson  <tejohnson@google.com>
>
>          * tree-ssa-threadupdate.c (ssa_fix_duplicate_block_edges):
>          Update redirected out edge count in joiner case.
>          (ssa_redirect_edges): Common the joiner and non-joiner cases
>          so that joiner case gets profile updates.
>
>          * testsuite/gcc.dg/tree-ssa/ssa-dom-thread-3.c (expand_one_var):
>          Update for additional dump message.
Thanks for the fix & cleanup.  OK for the trunk.

Jeff
Jeff Law Sept. 30, 2013, 8:06 p.m. UTC | #2
On 09/30/13 13:07, Jeff Law wrote:
> On 09/30/13 12:52, Teresa Johnson wrote:
>> The jump threading handling in the case of a joiner block was not
>> updating
>> profile information (it was being updated in the non-joiner case). Added
>> profile updates for the joiner case, in one place by commoning the
>> handling between the joiner and non-joiner cases.
>>
>> Bootstrapped and tested on x86_64-unknown-linux-gnu. Ok for trunk?
>>
>> Thanks,
>> Teresa
>>
>> 2013-09-30  Teresa Johnson  <tejohnson@google.com>
>>
>>          * tree-ssa-threadupdate.c (ssa_fix_duplicate_block_edges):
>>          Update redirected out edge count in joiner case.
>>          (ssa_redirect_edges): Common the joiner and non-joiner cases
>>          so that joiner case gets profile updates.
>>
>>          * testsuite/gcc.dg/tree-ssa/ssa-dom-thread-3.c (expand_one_var):
>>          Update for additional dump message.
> Thanks for the fix & cleanup.  OK for the trunk.
BTW, I'm going to go ahead and check this in -- it's conflicts with a 
patch that I was trying to wrap up today...

jeff
Teresa Johnson Sept. 30, 2013, 8:11 p.m. UTC | #3
Oh, I can do that right now if you want - let me know if you haven't
hit the trigger yet. Thanks,
Teresa

On Mon, Sep 30, 2013 at 1:06 PM, Jeff Law <law@redhat.com> wrote:
> On 09/30/13 13:07, Jeff Law wrote:
>>
>> On 09/30/13 12:52, Teresa Johnson wrote:
>>>
>>> The jump threading handling in the case of a joiner block was not
>>> updating
>>> profile information (it was being updated in the non-joiner case). Added
>>> profile updates for the joiner case, in one place by commoning the
>>> handling between the joiner and non-joiner cases.
>>>
>>> Bootstrapped and tested on x86_64-unknown-linux-gnu. Ok for trunk?
>>>
>>> Thanks,
>>> Teresa
>>>
>>> 2013-09-30  Teresa Johnson  <tejohnson@google.com>
>>>
>>>          * tree-ssa-threadupdate.c (ssa_fix_duplicate_block_edges):
>>>          Update redirected out edge count in joiner case.
>>>          (ssa_redirect_edges): Common the joiner and non-joiner cases
>>>          so that joiner case gets profile updates.
>>>
>>>          * testsuite/gcc.dg/tree-ssa/ssa-dom-thread-3.c (expand_one_var):
>>>          Update for additional dump message.
>>
>> Thanks for the fix & cleanup.  OK for the trunk.
>
> BTW, I'm going to go ahead and check this in -- it's conflicts with a patch
> that I was trying to wrap up today...
>
> jeff
>
Teresa Johnson Sept. 30, 2013, 8:12 p.m. UTC | #4
Nevermind - see that you did this already. Thanks!
Teresa

On Mon, Sep 30, 2013 at 1:11 PM, Teresa Johnson <tejohnson@google.com> wrote:
> Oh, I can do that right now if you want - let me know if you haven't
> hit the trigger yet. Thanks,
> Teresa
>
> On Mon, Sep 30, 2013 at 1:06 PM, Jeff Law <law@redhat.com> wrote:
>> On 09/30/13 13:07, Jeff Law wrote:
>>>
>>> On 09/30/13 12:52, Teresa Johnson wrote:
>>>>
>>>> The jump threading handling in the case of a joiner block was not
>>>> updating
>>>> profile information (it was being updated in the non-joiner case). Added
>>>> profile updates for the joiner case, in one place by commoning the
>>>> handling between the joiner and non-joiner cases.
>>>>
>>>> Bootstrapped and tested on x86_64-unknown-linux-gnu. Ok for trunk?
>>>>
>>>> Thanks,
>>>> Teresa
>>>>
>>>> 2013-09-30  Teresa Johnson  <tejohnson@google.com>
>>>>
>>>>          * tree-ssa-threadupdate.c (ssa_fix_duplicate_block_edges):
>>>>          Update redirected out edge count in joiner case.
>>>>          (ssa_redirect_edges): Common the joiner and non-joiner cases
>>>>          so that joiner case gets profile updates.
>>>>
>>>>          * testsuite/gcc.dg/tree-ssa/ssa-dom-thread-3.c (expand_one_var):
>>>>          Update for additional dump message.
>>>
>>> Thanks for the fix & cleanup.  OK for the trunk.
>>
>> BTW, I'm going to go ahead and check this in -- it's conflicts with a patch
>> that I was trying to wrap up today...
>>
>> jeff
>>
>
>
>
> --
> Teresa Johnson | Software Engineer | tejohnson@google.com | 408-460-2413
Jeff Law Sept. 30, 2013, 8:12 p.m. UTC | #5
On 09/30/13 14:11, Teresa Johnson wrote:
> Oh, I can do that right now if you want - let me know if you haven't
> hit the trigger yet. Thanks,
Already done :-0

jeff
diff mbox

Patch

Index: tree-ssa-threadupdate.c
===================================================================
--- tree-ssa-threadupdate.c     (revision 202947)
+++ tree-ssa-threadupdate.c     (working copy)
@@ -403,6 +403,7 @@  ssa_fix_duplicate_block_edges (struct redirection_
         threading through.  That's the edge we want to redirect.  */
       victim = find_edge (rd->dup_block, THREAD_TARGET (e)->dest);
       e2 = redirect_edge_and_branch (victim, THREAD_TARGET2 (e)->dest);
+      e2->count = THREAD_TARGET2 (e)->count;

       /* If we redirected the edge, then we need to copy PHI arguments
         at the target.  If the edge already existed (e2 != victim case),
@@ -497,18 +498,8 @@  ssa_redirect_edges (struct redirection_data **slot
       free (el);

       thread_stats.num_threaded_edges++;
-      /* If we are threading through a joiner block, then we have to
-        find the edge we want to redirect and update some PHI nodes.  */
-      if (THREAD_TARGET2 (e))
-       {
-         edge e2;

-         /* We want to redirect the incoming edge to the joiner block (E)
-            to instead reach the duplicate of the joiner block.  */
-         e2 = redirect_edge_and_branch (e, rd->dup_block);
-         flush_pending_stmts (e2);
-       }
-      else if (rd->dup_block)
+      if (rd->dup_block)
        {
          edge e2;

@@ -522,9 +513,15 @@  ssa_redirect_edges (struct redirection_data **slot
             the computation overflows.  */
          if (rd->dup_block->frequency < BB_FREQ_MAX * 2)
            rd->dup_block->frequency += EDGE_FREQUENCY (e);
-         EDGE_SUCC (rd->dup_block, 0)->count += e->count;
-         /* Redirect the incoming edge to the appropriate duplicate
-            block.  */
+
+          /* In the case of threading through a joiner block, the outgoing
+             edges from the duplicate block were updated when they were
+             redirected during ssa_fix_duplicate_block_edges.  */
+          if (!THREAD_TARGET2 (e))
+            EDGE_SUCC (rd->dup_block, 0)->count += e->count;
+
+         /* Redirect the incoming edge (possibly to the joiner block) to the
+             appropriate duplicate block.  */
          e2 = redirect_edge_and_branch (e, rd->dup_block);
          gcc_assert (e == e2);
          flush_pending_stmts (e2);
Index: testsuite/gcc.dg/tree-ssa/ssa-dom-thread-3.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/ssa-dom-thread-3.c        (revision 202947)
+++ testsuite/gcc.dg/tree-ssa/ssa-dom-thread-3.c        (working copy)
@@ -42,7 +42,7 @@  expand_one_var (tree var, unsigned char toplevel,
     abort ();
 }
 /* We should thread the jump, through an intermediate block.  */
-/* { dg-final { scan-tree-dump-times "Threaded" 1 "dom1"} } */
+/* { dg-final { scan-tree-dump-times "Threaded" 2 "dom1"} } */
 /* { dg-final { scan-tree-dump-times "Registering jump thread:
\\(.*\\) incoming edge;  \\(.*\\) joiner;  \\(.*\\) nocopy;" 1 "dom1"}
} */