Skip to content

JIT: PGO: fgOptimizeUncondBranchToSimpleCond corrupts profile data #50419

Closed
@EgorBo

Description

@EgorBo

It looks like fgOptimizeUncondBranchToSimpleCond (as part of the Optimize Layouts phase) produces invalid weights in some cases. E.g.

Before Optimize layout:
image

^ all edges look valid and satisfy Kirchhoff's Law.

After Optimize Layouts:

image

^
invalid edges:
BB06 (in: 0 + 0.5, out: 1)
BB09 (in: 0.25, out: 0)

I guess invalid edges are fine and will be re-calculated, but there are also invalid blocks such as BB09 which is a predecessor of a cold block but has weight 0.5 (BB05 should also be cold then?)

As the result, in the end I have:

; with IBC profile data, edge weights are invalid, and fgCalledCount is 36

But if I disable fgOptimizeUncondBranchToSimpleCond the final weights will be reported as valid:

image

^ "After Optimize Layout" without fgOptimizeUncondBranchToSimpleCond, all blocks look valid again (edges aren't though).

/cc @AndyAyersMS

category:correctness
theme:profile-feedback
skill-level:beginner
cost:small
impact:small

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIin-prThere is an active PR which will close this issue when it is mergedtenet-performancePerformance related issue

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions