[PATCH] D10979: Update the branch weight metadata in JumpThreading pass.

Xinliang David Li davidxl at google.com
Tue Jul 7 13:24:15 PDT 2015


On Tue, Jul 7, 2015 at 10:39 AM, Duncan P. N. Exon Smith
<dexonsmith at apple.com> wrote:
>
>> On 2015-Jul-06, at 17:22, Cong Hou <congh at google.com> wrote:
>>
>>
>> congh added reviewers: chandlerc, davidxl.
>> congh added a subscriber: llvm-commits.
>>
>> Currently in JumpThreading pass, the branch weight metadata is not updated after CFG modification. Consider the jump threading on PredBB, BB, and SuccBB. After jump threading, the weight on BB->SuccBB should be adjusted as some of it is contributed by the edge PredBB->BB, which doesn't exist anymore. This patch tries to update the edge weight in metadata on BB->SuccBB by scaling it by 1 - Freq(PredBB->BB) / Freq(BB->SuccBB). Two more analyses (BlockFrequencyInfo and BranchProbabilityInfo) are needed then.
>
> Thanks for working on this!
>
> Generally you don't need these analyses to keep branch weights
> up-to-date.  The design premise is that you don't need global
> information for local updates.
>

This is true in general, but probably not the case for jump-threading.
When a new thread is formed (from NewBB to SuccBB), the  profile
update delta to the original edge BB->SuccBB comes from a different
edge (Pred->NewBB which is inherited from Pred->BB). Local update by
only looking at BB seems impossible.

> You should be able to calculate the new !prof attachment based on the
> old ones, without running BFI.  (I'm skeptical of even running BPI -- if
> there's no !prof attachment on the old block, then you have no real
> information; what's the benefit in generating a new !prof attachment
> based on heuristics?  The new CFG will come with its own new
> heuristics.)
>

I believe Cong's fix is targeting PGO.

David

> Please reformulate this calculation in terms of local branch weights
> instead of block frequency.
>
>> http://reviews.llvm.org/D10979
>>
>> Files:
>>  lib/Transforms/Scalar/JumpThreading.cpp
>>
>> <D10979.29140.patch>_______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list