[PATCH] D22696: [CodeGenPrep] Skip merging empty case blocks

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 4 10:54:11 PDT 2016


can you isolate one small case and show the final code with/without the change?

I can see a couple of issues:
1) the cost of direct branch can be modelled better
2) static profile can get it quite wrong if the branch prediction
heuristic is wrong. Do you see similar regression with PGO?  I can see
without PGO, we should indeed  make the frequency ratio to be much
larger (i.e., require more cases in switch).

David

On Tue, Oct 4, 2016 at 10:26 AM, Jun Bum Lim <junbuml at codeaurora.org> wrote:
> junbuml added a comment.
>
> As of now, with/without this change (with FreqRatio=2), I can see  6.7% more https://reviews.llvm.org/L1 I-cache miss from perf-stat. I didn’t try to narrow down to the place in which the regression was caused, but I printed out FreqRatio, NumCopyInsertionPHIs, and NumOfCases when this change applied and I can see this was applied even when the number of cases in switch is small enough due to the aggressive FreqRatio=2.  Please let me know if you want me to further narrow down.
>
> FreqRatio: 160 , NumCopyInsertionPHIs : 1, NumCase: 5
> FreqRatio: 102 , NumCopyInsertionPHIs : 1, NumCase: 3
> FreqRatio: 786 , NumCopyInsertionPHIs : 16, NumCase: 793
> FreqRatio: 64 , NumCopyInsertionPHIs : 1, NumCase: 2
> FreqRatio: 128 , NumCopyInsertionPHIs : 1, NumCase: 4
> FreqRatio: 128 , NumCopyInsertionPHIs : 0, NumCase: 4
> FreqRatio: 128 , NumCopyInsertionPHIs : 0, NumCase: 4
> FreqRatio: 128 , NumCopyInsertionPHIs : 0, NumCase: 4
> FreqRatio: 128 , NumCopyInsertionPHIs : 0, NumCase: 4
> FreqRatio: 128 , NumCopyInsertionPHIs : 0, NumCase: 4
> FreqRatio: 128 , NumCopyInsertionPHIs : 0, NumCase: 4
> FreqRatio: 128 , NumCopyInsertionPHIs : 0, NumCase: 4
> FreqRatio: 128 , NumCopyInsertionPHIs : 0, NumCase: 4
> FreqRatio: 8 , NumCopyInsertionPHIs : 5, NumCase: 7
> FreqRatio: 8 , NumCopyInsertionPHIs : 5, NumCase: 7
> FreqRatio: 8 , NumCopyInsertionPHIs : 5, NumCase: 7
> FreqRatio: 8 , NumCopyInsertionPHIs : 5, NumCase: 7
> FreqRatio: 8 , NumCopyInsertionPHIs : 5, NumCase: 7
> FreqRatio: 8 , NumCopyInsertionPHIs : 5, NumCase: 7
> FreqRatio: 8 , NumCopyInsertionPHIs : 5, NumCase: 7
> FreqRatio: 8 , NumCopyInsertionPHIs : 5, NumCase: 7
> FreqRatio: 8 , NumCopyInsertionPHIs : 5, NumCase: 7
> FreqRatio: 8 , NumCopyInsertionPHIs : 5, NumCase: 7
> FreqRatio: 32 , NumCopyInsertionPHIs : 1, NumCase: 7
> FreqRatio: 32 , NumCopyInsertionPHIs : 1, NumCase: 8
> FreqRatio: 32 , NumCopyInsertionPHIs : 3, NumCase: 4
> FreqRatio: 96 , NumCopyInsertionPHIs : 0, NumCase: 3
> FreqRatio: 64 , NumCopyInsertionPHIs : 0, NumCase: 2
> FreqRatio: 39 , NumCopyInsertionPHIs : 0, NumCase: 32
> FreqRatio: 1024 , NumCopyInsertionPHIs : 0, NumCase: 32
> FreqRatio: 1024 , NumCopyInsertionPHIs : 0, NumCase: 32
> FreqRatio: 39 , NumCopyInsertionPHIs : 1, NumCase: 32
> FreqRatio: 864 , NumCopyInsertionPHIs : 0, NumCase: 27
> FreqRatio: 32 , NumCopyInsertionPHIs : 0, NumCase: 2
> FreqRatio: 64 , NumCopyInsertionPHIs : 1, NumCase: 3
> FreqRatio: 64 , NumCopyInsertionPHIs : 1, NumCase: 3
> FreqRatio: 64 , NumCopyInsertionPHIs : 1, NumCase: 3
> FreqRatio: 64 , NumCopyInsertionPHIs : 1, NumCase: 3
> FreqRatio: 193 , NumCopyInsertionPHIs : 1, NumCase: 6
>
>
> https://reviews.llvm.org/D22696
>
>
>


More information about the llvm-commits mailing list